html - 如何让文本覆盖在图像上?

标签 html css image overlay

我似乎无法让显示的文本覆盖在图像上。我已经在 codepen 中测试了代码片段,并且可以在那里获得预期的效果。

HTML:

   <div class="container-fluid">
    <div class="row">
        <div class="banner">
            <img src="https://imageshack.com/a/img923/9364/qvCJa4.png" pagespeed_url_hash="616443323" onload="pagespeed.CriticalImages.checkImageForCriticality(this);" />

            <div class="container-fluid purchaceNowOverlayText">
                <div class="row">
                    <div class=" col-sm-1">
                        <hr>
                    </div>
                    <div class="col-sm-11">
                        <h2>Are you Ready? <b>Purchace Here!</b></h2>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-12 col-md-6 col-lg-6 headerRow">
                        <img src="images/3bottlesdone.png" width="400px" height="300px">
                    </div>
                    <div class="col-sm-12 col-md-6 col-lg-6 headerRow">
                        <p>This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image This text should overlay over the bg image </p>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

CSS:

.banner{ position:relative; width:90%; margin:0 auto; }  
.banner img{width:100%;}
.purchaceNowOverlayext{position:absolute; top:50%; color: white;}

最佳答案

打字错误。您的 CSS 类在 purchaceNowOverlayText

上缺少 T

关于html - 如何让文本覆盖在图像上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48733802/

相关文章:

c# - 我的按钮没有回发?我将它与 Javascript 绑定(bind)在一起,而 Javascript 又与 div 绑定(bind)在一起

php - 制作链接提示 'save as'的简单方法

c# - 使用套接字通过网络发送图像,数据困惑

css - 如何建立像 Reddit 那样的 img-div 关系?

google-chrome - 当溢出时,最后一个子元素的下边距会被隐藏

php - 在 php 数组循环中放置图像标签的正确方法

html - Zalgo 文本如何工作?

javascript - 样式为按钮的复选框输入不再触发 'change' 事件

html - border-radius with box-shadow inset 像素化/粗糙

css - 带过渡的下拉菜单