gpt4 book ai didi

html - 如何在图像上添加半透明框并右对齐?

转载 作者:行者123 更新时间:2023-11-28 09:11:14 24 4
gpt4 key购买 nike

我想在图像上添加一个半透明的文本框,该框需要右对齐,但不知道该怎么做,有人可以帮忙吗?

我在这里模拟了页面:http://dev.gigiscucina.co.uk/ ,截图如下。红色 block 只是占位符。

enter image description here

HTML 如下。我希望能够在 home_widget_2(文本右对齐)和主页 home_widget_4(文本左对齐)上添加半透明文本 block 。

<div id="home_widget_1" class="grid col-300">
<div id="text-2" class="widget-wrapper widget_text">
<div class="textwidget"><img src="http://dev.gigiscucina.co.uk/wp-content/uploads/2014/10/300.jpg" alt= ""></div>
</div>
</div><!-- end of .col-300 -->

<div id="home_widget_2" class="grid col-620 fit">
<div id="text-3" class="widget-wrapper widget_text">
<div class="textwidget"><img src="http://dev.gigiscucina.co.uk/wp-content/uploads/2014/10/620.jpg" alt= ""></div>
</div>
</div><!-- end of .col-620 fit -->

<div id="home_widget_3" class="grid col-620">
<div id="text-4" class="widget-wrapper widget_text">
<div class="textwidget"><img src="http://dev.gigiscucina.co.uk/wp-content/uploads/2014/10/620.jpg" alt= ""></div>
</div>
</div><!-- end of .col-620 -->

<div id="home_widget_4" class="grid col-300 fit">
<div id="text-5" class="widget-wrapper widget_text">
<div class="textwidget"><img src="http://dev.gigiscucina.co.uk/wp-content/uploads/2014/10/300.jpg" alt= ""></div>
</div>
</div><!-- end of .col-300 fit -->

最佳答案

.box { 
position: relative;
width:300px;
}

.box p {
position: absolute;
bottom: 0;
right: 0;
background-color:rgba(0,0,0,0.75);
color:#ffffff;
padding:5px;
}
<div class="box">
<img src="image.png" width="300" alt="" />
<p>this is where your text will go<br />change image size according to div width</p>
</div>

关于html - 如何在图像上添加半透明框并右对齐?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26497071/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com