我正在尝试在背景上添加背景图像,但是我无法使用此代码显示图像的完整尺寸。当我尝试使用background-size auto时,我得到了正确的宽度,但是高度很小,我知道这取决于内容的大小。但还是有办法
<div style="background: url('https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/1%20(2).jpg?alt=media&token=48244df9-a2bb-412a-81f5-854e2dbc4939');background-repeat: no-repeat;background-size:500px 500px;">
<a href ="https://github.com/" style="text-decoration: none;">
<table>
<tr>
<td><h3 style="color: #fff;">Amarjeet Singh</h3></td>
</tr>
<tr>
</tr>
</table>
</a>
</div>
图像设置为您的背景<div>
所以它的大小将取决于width
和height
的那个<div>
。因此,如果高度较大,background-image
则会显示更多。只是为了说明,请查看下面的代码。我给<div>
了一个height : 600px
,图像现在显示该高度。
简而言之,背景图片仅显示元素的大小。您的元素越大,就会出现越多的图像。
<div class="container"
style=" height: 600px; /* Just to illustrate */
position: relative;
background: url('https://firebasestorage.googleapis.com/v0/b/growthfilepractice.appspot.com/o/1%20(2).jpg?alt=media&token=48244df9-a2bb-412a-81f5-854e2dbc4939');
background-repeat: no-repeat;
background-size:500px 500px;">
<a class="nameAnchor"
href ="https://github.com/"
style=" text-decoration: none;
position: absolute;
color: white;
left: 10px; /* Set your Left position here */
top: 100px; /* set your top position here */
">
<span>Amarjeet Singh</span>
</a>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句