Created
July 23, 2015 07:50
-
-
Save redgoose-dev/e4ee048cbb707dff1179 to your computer and use it in GitHub Desktop.
border hair line. border-width: 0.5px
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="ko"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>hair line demo</title> | |
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> | |
<link rel="stylesheet" href="./style.css"/> | |
</head> | |
<body> | |
<h1>hair line demo</h1> | |
<div class="line1"></div> | |
<div class="line2"></div> | |
<div class="line3"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* create hairline | |
* | |
* @param boolean $type line type (true: vertical, false: horizontal) | |
* @param hex $color background-color | |
*/ | |
@mixin hairline($type: false, $color: null) | |
{ | |
overflow: hidden; | |
-webkit-transform-origin: 0 0; | |
@if $type == false { | |
height: 1px; | |
margin-bottom: -0.5px; | |
-webkit-transform: scaleY(0.5); | |
} | |
@else { | |
width: 1px; | |
-webkit-transform: scaleX(0.5); | |
} | |
@if $color { | |
background: $color; | |
} | |
} | |
h1 { | |
font-size: 20px; | |
font-family: Helvetica, sans-serif; | |
} | |
.line1 { | |
@include hairline(false, red); | |
} | |
.line2 { | |
@include hairline(true, blue); | |
height: 100px; | |
} | |
.line3 { | |
@include hairline(false, black); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
고해상도 환경에서 1px로 선을 만들었는데 2px로 보이는 현상이 있어 대안 중 하나.
선을 일일히 만들어줘야하는 삽질이 필요함.