아랄라랄라
R 스토리
아랄라랄라
전체 방문자
오늘
어제
  • All (197)
    • Web (144)
      • Markup | WEB (9)
      • Styles (45)
      • javascript (32)
      • jquery (28)
      • vue (16)
      • react (10)
      • more (4)
    • IT (31)
      • CS (3)
      • git hub (5)
      • UI | UX (18)
      • more (5)
    • ETC (22)
      • 이슈노트 (12)
      • 스터디 (10)
      • 아랄라 ☞☜ (0)
      • JOB🛠 (0)

인기 글

반응형
hELLO · Designed By 정상우.
아랄라랄라

R 스토리

[CSS] 모서리 자르기
Web/Styles

[CSS] 모서리 자르기

2020. 12. 29. 01:21

 

 

 

 

 

 

 

HTML

<h2>모서리 한개</h2>
<div class="button top-left">BUTTON</div>
<div class="button top-right">BUTTON</div>
<div class="button bottom-right">BUTTON</div>
<div class="button bottom-left">BUTTON</div>

<h2>모서리 두개</h2>
<div class="button top">BUTTON</div>
<div class="button bottom">BUTTON</div>

<h2>모서리 여러개</h2>
<div class="button topbottom">BUTTON</div>

 

CSS

body {
	background: #ddd;
}

.button {
	width: 150px;
	line-height: 40px;
	text-align: center;
	margin-bottom: 20px;
}

.top-left {
	background: linear-gradient(135deg, transparent 10px, #58a 0);
}

.top-right {
	background: linear-gradient(-135deg, transparent 10px, #58a 0);
}

.bottom-right {
	background: linear-gradient(-45deg, transparent 10px, #58a 0);
}

.bottom-left {
	background: linear-gradient(45deg, transparent 10px, #58a 0);
}


.top {
	background: linear-gradient(-135deg, transparent 10px, #58a 0) right, linear-gradient(135deg, transparent 10px, #58a 0) left;
	background-size: 50% 100%;
	background-repeat: no-repeat;
}

.bottom {
	background: linear-gradient(-45deg, transparent 10px, #58a 0) right, linear-gradient(45deg, transparent 10px, #58a 0) left;
	background-size: 50% 100%;
	background-repeat: no-repeat;
}

 

SCSS mixin

/* mixin */
@mixin beveled-corners($bg, $tl:0, $tr:$tl, $br:$tl, $bl:$tr) {
    background: linear-gradient(135deg, transparent $tl, $bg 0) top left, linear-gradient(-135deg, transparent $tr, $bg 0) top right, linear-gradient(-45deg, transparent $br, $bg 0) bottom right, linear-gradient(45deg, transparent $bl, $bg 0) bottom left;
    background-size: 50% 50%;
    background-repeat: no-repeat;
}

.topbottom {
    @include beveled-corners(#58a, 5px);
}

 

 

 

 

 

 


참고 : css시크릿 책

 

 

 

728x90
저작자표시 비영리

'Web > Styles' 카테고리의 다른 글

[CSS] 국가별 기본 웹폰트  (0) 2021.04.29
[CSS] css 선언 순서  (0) 2021.03.19
[CSS] 웹페이지 프린트 설정  (1) 2020.05.18
[CSS] footer 하단에 고정 시키기  (0) 2020.05.13
[CSS] display:flex 속성  (0) 2020.03.05

티스토리툴바