gpt4 book ai didi

html - 如何使用 css 使背景图像可见?

转载 作者:太空宇宙 更新时间:2023-11-03 20:17:06 24 4
gpt4 key购买 nike

我试着用背景图片短信制作div。当我将 width 设置为 100% 并将 height 设置为 auto 时,一切都完美无缺。我将 div 高度设置为自动,因为每当我增加 文本的字体大小 时,div 高度也会动态增加。但现在我的问题是,当我在 div 中留下空消息时,它不会显示任何内容,因为 height:auto 我想显示具有实际背景图像的 div。即使我留下的消息是空的。是否可以显示高度为自动的背景图像。

这是我的代码:

#loginContainer {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
background: url("http://s3.buysellads.com/1237708/176570-1371740695.gif")
no-repeat scroll center center #FF660D; /*for example */
border-color: #FFFFFF;
border-image: none;
border-right: medium solid #FFFFFF;
border-style: none solid solid;
border-width: medium;
left: 0;
margin-left: auto;
margin-right: auto;
position: fixed;
right: 0;
top: 0;
vertical-align: super;
width: 100%;
z-index: 9999999;
}

这是 fiddle

这是 fiddle 在 div 中有空消息

最佳答案

div 添加一个最小高度,如下所示:

#loginContainer {
min-height: 200px;
}

Working Sample

关于html - 如何使用 css 使背景图像可见?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18658272/

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