thisのような背景画像の上に透明なボックスを作成する際に問題があります。私のコードはほぼ同じですが、なんらかの理由で透明なボックスを画像の上から移動させることはできません(ボックスを上下のマージンに合わせたいと思います)。パディングを追加:バックグラウンドに20pxは何もしません。マージンを#transboxに20px追加すると、左右のマージンは20pxだけ増加しますが、上下のマージンは何もしません。画像の上に透明なボックスのテキストはありますか?
HTML & CSS:
.background {
background-image: url("https://source.unsplash.com/5OMTuqOM7bI");
}
#transbox {
background-color: rgba(255, 255, 255, 0.8);
padding: 20px;
margin: 60px;
}
h3 {
text-align: center;
font-weight: 300;
color: #3C5FA3;
}
.container {
width: 80%;
margin: 0 auto;
padding: 0 30px;
}
.clearfix:after {
visibility: hidden;
display: block;
content: "";
clear: both;
height: 0;
}
<div class="container clearfix background">
<div id="transbox">
<h3>Some text here</h3>
</div>
</div>
'padding:0 30px;'は 'padding-top:0;と同じです。パディング - 右:30px; padding-bottom:0; padding-left:30px; ' – connexo
*' .background'に 'padding:20px;'を加えることは何もしません。*後でCSSで '.container'でこのパディングを上書きするからです。 – connexo