Help us understand the problem. What is going on with this article?

box-shadowでグラデーションボーダーを作ってみた

More than 3 years have passed since last update.

スクリーンショット 2015-08-24 16.03.00.png

html

<div id="wrap">
  <h1>box-shadowを使って要素の隅に色をつけています</h1>
</div>

CSS

#wrap{
  box-shadow:
     30px  30px 50px 0 orange inset,
    -30px -30px 50px 0 orange inset;

  padding: 45px; /* (box-shadow)offset-x,offset-y * 1.5 */
  box-sizing: border-box;
}

解説

box-shadow
inset 影をボックスの内側に描画できる

inset指定で offsetの値をマイナスにすると要素右下から描画される
スクリーンショット 2015-08-24 16.12.37.png

inset指定で offsetの値をプラスにすると要素左上から描画される
スクリーンショット 2015-08-24 16.11.57.png

これを組み合わせて要素を囲んでいる。

box-shadowの広がりを使うパターン

#wrap{
  box-shadow: 0 0 50px 30px orange inset;
  padding: 50px; /* ぼかし値と合わせる */
  box-sizing: border-box;
}

box-shadowの広がりを利用すれば実現できる。
スクリーンショット 2015-08-25 13.54.47.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした