5月更新・前月(4月)の人気記事トップ10 05/01/2022
- ( 03 ↑) 【Mac】MacにGoogle Driveをインストール
- ( 01 ↓) 【Mac】Macのユーザー名とアカウント名を変更する
- ( 02 ↓) 【iPhone iPad】iPhoneやiPadの音量を細かく調整する方法
- ( 04 − ) 【iPhone / iPad】iPhoneでSuicaをクレジットカード無しで使う方法
- ( 05 − ) 【jQuery】入門2. jQueryをHTMLに組み込む
- ( 07 ↑) 【Labs】position:absoluteとwidth:100%を指定すると横幅の設定がうまくいかない場合の対処方法について
- (圏外↑) 【jQuery】入門5. jQueryで日時を表示
- ( 06 ↓) 【Labs】CSSだけでドロップダウンメニュー
- ( 09 − ) 【Labs】スマホ対応CSSだけでドロップダウンメニュー
- (圏外↑) 【JavaScript】addEventListenerの基本的な書き方 その3
【CSS3リファレンス】background-clip
こんにちは(・∀・)
CSS3で新しく追加されたプロパティをご紹介します。今回ご紹介するCSSプロパティはbackground-clipです。
概要
background-clipプロパティはborderプロパティとbackground-imageプロパティが設定されている要素の背景画像の表示の仕方を指定する事ができるプロパティです。
.sample {
background-clip: border-box;
}
適用要素
すべての要素
指定できる値
- border-box
- 背景画像をborder領域と重ねて表示
- padding-box
- 背景画像をborderの内側から表示
- content-box
- 要素にpaddingが設定されている場合paddingの内側から背景画像を表示
初期値
border-box
サンプル
HTML
<p class="demo1">
border-box
背景画像をborder領域と重ねて表示します。
</p>
<p class="demo2">
padding-box
背景画像をborderの内側から表示します。
</p>
<p class="demo3">
content-box
要素にpaddingが設定されている場合、paddingの内側から背景画像を表示します。
</p>
CSS
.demo1,
.demo2,
.demo3 {
padding:10px;
background: url(sample.jpg) top left no-repeat;
border: 10px dashed #777;
}
.demo1 {
background-clip: border-box;
}
.demo2 {
background-clip: padding-box;
}
.demo3 {
background-clip: content-box;
}
Result
border-box
背景画像をborder領域と重ねて表示します。
padding-box
背景画像をborderの内側から表示します。
content-box
要素にpaddingが設定されている場合、paddingの内側から背景画像を表示します。