gpt4 book ai didi

html - 背景颜色填充文本后面 div 的前 70px

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

有没有更简单的方法呢?我只想让背景颜色填充 div 的顶部宽度,70px 高和 div 的整个宽度,在本例中为 400px。我能够找到一个解决方案,但它看起来很难看。抱歉,我正在使用内联样式,因为我无法轻松地将新 CSS 添加到 6,500 页的网站。

<div style="border: 1px solid #bbb;  padding:20px; width:400px; height:150px; float:left; margin-right:60px;">
<div style="background:#cccccc; width:440px; height:40px; padding:0; position:relative; margin-left:-20px; margin-top:-20px;"></div>
<div style="background:#cccccc; width:420px; height:30px; padding-left:20px; position:relative; margin-left:-20px; margin-top:-20px;">
<p><b>To learn more:</b></p>
</div>
<p><a href="#" class="btn btn-primary">Contact a sales rep</a></p>
</div>

JS Fiddle

最佳答案

您可以使用linear-gradient

background: #eeeeee; /* Old browsers */
background: -moz-linear-gradient(top, #eeeeee 0%, #eeeeee 70px, #ffffff 70px, #ffffff 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eeeeee), color-stop(70px,#eeeeee), color-stop(70px,#ffffff), color-stop(100%,#ffffff)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #eeeeee 0%,#eeeeee 70px,#ffffff 70px,#ffffff 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #eeeeee 0%,#eeeeee 70px,#ffffff 70px,#ffffff 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #eeeeee 0%,#eeeeee 70px,#ffffff 70px,#ffffff 100%); /* IE10+ */
background: linear-gradient(to bottom, #eeeeee 0%,#eeeeee 70px,#ffffff 70px,#ffffff 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */

http://www.colorzilla.com/gradient-editor/ 生成的代码

关于html - 背景颜色填充文本后面 div 的前 70px,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30672993/

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