4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

端の丸いBorder

Last updated at Posted at 2016-07-21

仕様

スクリーンショット 2016-07-21 14.37.09.png

端が丸くなってるBorderをCSSで実装

ソース

例は左の場合。
:before:after で該当要素のborderと同じ値の丸を作って、positionで位置調整すればOK。
Sassで書くのでどこの値がどうなるってのはソース参考に。

round-cap-border.scss
$width__border: 6px;
$color__border: red;
h1 {
  font-size: 18px;
  border-left-style: solid;
  border-left-width: $width__border;
  border-left-color: $color__border;
  position: relative;
  padding-left: 10px;
  &:before,
  &:after {
    content: ' ';
    background-color: $color__border;
    width: $width__border;
    height: $width__border;
    border-radius: ($width__border/2);
    display: block;
    position: absolute;
    left: -($width__border);
  }
  &:before {
    top: -($width__border/2);
  }
  &:after {
    bottom: -($width__border/2);
  }
}

デモはこちら
https://jsfiddle.net/gatespace/4p8z2jgf/

4
3
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?