gpt4 book ai didi

css - div 高度显示不正确

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

我有一个 div 元素,里面有两个 div 元素,内部 div 是 float 的。但我想要具有自动高度的主 div。不固定。并且背景必须正确显示。当我将高度设置为 250px 时,背景仅显示 250px 区域。但是当我将高度设置为 auto 时,背景没有显示。如何使背景显示为自动高度?

我的 HTML 代码:-

<div class="ejz_wc" id="ejz_wc">
<div class="ejz_wc_main" id="ejz_wc_main">
<div class="ejz_wcm_txt">
<h2 class="ejz_wc_1_h2">Welcome</h2>
<p class="ejz_wc_msg">
If you are new to us then Register a free account today .<br />
We are here to give you entertainment
</p>
<div class="wclinks">
<a href="<? echo $url; ?>/info/about.php">Learn moare about us</a><br />
<a href="<? echo $url; ?>/info/payment.php">Learn more about Payment</a><br /><br />
<a href="ez-register.php#free">Register</a> for a free Account<br />
<a href="ez-register.php#performer">Register</a> for a Premium Account<br />
</div>
</div>
<div class="ejz_wc_box">
<div class="ejz_wcbox">
<h3>Sign In</h3>
<p>Sign in to us

<center><a class="lnksnrg" href="ez-login.php"><div class="signin_ejz">Login</div></a></center>
<h3>Not registered yet?</h3>
Register now and get access to all items.</p>
<br />
<center><a class="lnksnrg" href="ez-login.php"><div class="register_ejz">Register</div></a></center>
</div>
</div>
</div>
</div>

我的 CSS 代码是:-

.ejz_wc
{
width:900px;
margin:auto;
height:250px;
}
.ejz_wc_main
{
font-family: 'Segoe UI','Tahoma Bold','Arial Bold','Helvetica Bold',sans-serif;
height:100%;
border-radius:10px;
-moz-border-radius:10px;
width:100%;
background:#f4f4f4;
}
.ejz_wcm_txt a
{
text-decoration:none;
}
.ejz_wcm_txt a:hover
{
text-decoration:underline;
}
.ejz_wcm_txt
{
float:left;height:auto;
width:450px;
padding:10px 20px;
font-family: 'Segoe UI','Tahoma Bold','Arial Bold','Helvetica Bold',sans-serif;
}
.ejz_wc_box
{
float:right;height:auto;
width:320px;
padding:10px;
font-family: 'Segoe UI','Tahoma Bold','Arial Bold','Helvetica Bold',sans-serif;
}
.ejz_wc_1_h2
{
font-family: 'Segoe UI','Tahoma Bold','Arial Bold','Helvetica Bold',sans-serif;
font-size:x-large;
color:#38939b;height:auto;
}
h1, h2, h3, h4, h5, h6
{
font-family: 'Segoe UI','Tahoma Bold','Arial Bold','Helvetica Bold',sans-serif;
}
.signin_ejz , .register_ejz
{
background:#019be1;
background: -moz-linear-gradient(019be1, #1a75d6);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #1a75d6),color-stop(1, #019be1));
background: -webkit-linear-gradient(#019be1, #1a75d6);
background: -o-linear-gradient(#019be1, #1a75d6);
background: -ms-linear-gradient(#019be1, #1a75d6);
background: linear-gradient(#019be1, #1a75d6);
padding:5px;
border-radius:10px;
-moz-border-radius:10px;
color:white;
text-decoration:none;
width:100px;
margin:auto;
border:2px solid #019be1;
}

.lnksnrg
{
text-decoration:none;
color:white;
}
.lnksnrg:hover
{
text-decoration:none;
}
.signin_ejz:hover , .register_ejz:hover
{
background:#019be1;
border:2px solid #019be1;
background: -moz-linear-gradient(1a75d6, #019be1);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #019be1),color-stop(1, #1a75d6));
background: -webkit-linear-gradient(#1a75d6, #019be1);
background: -o-linear-gradient(#1a75d6, #019be1);
background: -ms-linear-gradient(#1a75d6, #019be1);
background: linear-gradient(#1a75d6, #019be1Fwc);
}

最佳答案

在“.ejz_wc_main”中提及overflow:hidden 将解决您的问题。

.ejz_wc_main {
background: none repeat scroll 0 0 green;
border-radius: 10px 10px 10px 10px;
font-family: 'Segoe UI','Tahoma Bold','Arial Bold','Helvetica Bold',sans-serif;
height: 100%;
overflow: hidden;
width: 100%;
}

这是工作代码 jsFiddle File

关于css - div 高度显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17120343/

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