如何使.welcome-content-wrap
類拉伸以適應其內容並仍保持我給出的透明樣式?垂直拉伸div以適合內容
我明白,你通常不會添加背景圖片像我有但就是爲什麼我做它像我有一個理由
.welcome-section{
\t position: relative;
}
.welcome-background{
\t max-width: 100%;
\t display: block;
\t height: auto;
}
.welcome-content-wrap{
\t position: absolute;
\t top:10%;
\t left: 0;
\t right: 0;
\t bottom: 10%;
\t margin: 0 auto;
\t max-width: 800px;
\t background: rgb(0, 0, 0);
\t background: rgba(0, 0, 0, 0.7);
\t text-align: center;
}
.welcome-content-wrap img{
\t display: block;
\t width: 50%;
\t margin: 50px auto;
}
.welcome-content-wrap p{
\t color: #fff;
\t margin: 25px;
}
.text-style{
\t font-family: outstanding;
\t font-size: 0.75em;
}
<div class="welcome-section">
\t <img class="welcome-background" src="images/menuBackground.jpg">
\t <div class="welcome-content-wrap">
\t \t <img src="images/welcomeTransparent.png">
\t
\t \t <p>
\t \t \t <span class="text-style">WELCOME</span> to Popsie's of Bramhope a modern, local<br>
\t \t \t Yorkshire fish and chip shop. At Popsie's all our food is hand<br> prepared by Popsie's Dad in the shop's kitchen every day.
\t \t </p>
\t \t <p>All our fish is sourced from sustainable sources.</p>
\t \t <p>
\t \t \t We cook fish to order so that it isn't left to dry out under lights,<br>
\t \t \t like in too many chip shops.
\t \t </p>
\t \t <p>Our potatoes are from local Yorkshire & Lincolnshire farms and<br> we pride ourselves on using the best and freshest ingredients.</p>
\t
\t \t <img id="image-m" src="images/shutterstock_164403170.jpg">
\t \t <img id="image-l" src="images/National-federation-of-fish-logo.png">
\t \t <img id="image-r" src="images/CSSMSClogo.png">
\t </div>
</div>
原始代碼有'max-width:800px'。在查看比這更大的元素時,元素不會「水平拉伸」,因此完全可能他*實際上意味着水平*。如果您對這個問題不確定,或者認爲OP出錯,您應該對該問題發表評論,並要求澄清,而不是在您的答案中進行猜測。我不是說你不正確,我只是建議從OP得到澄清。 – justinw
事情是,在有50個聲望之前不能評論,所以怎麼問? – Lichtbringer
如果您無法評論,並且您對問題中的某些內容不確定,那麼您可能不應提交潛在的低質量答案。 – justinw