gpt4 book ai didi

html - 重叠/粘贴背景图像以重叠 div 的边框

转载 作者:行者123 更新时间:2023-11-28 12:35:37 25 4
gpt4 key购买 nike

我有一个页面,它分为两个主要的 div。一个是位于页面顶部的页眉,下面是一个页眉,它是页面内容的容器。标题可以在下面的代码片段中看到:

<link href="http://www.spareskills.com/css/compiled/theme.css" rel="stylesheet"/>
<body id="postajob">
<div class="header">
<div class="background-images img1 animated fadeInUpBig"></div>
<div class="container">
<div class="row">
<div class="col-md-12">
<h2 class="animated bounceInLeft">Post a job.</h2>
<p>
Find a job by filling out your application below. It really is easy.
<br>
<span class="hidden-xs">Explain the job you need and people with the right skills will be in touch</span>
</p>
</div>
</div>
</div>
</div>
</body>

下面列出了相关的 SASS/CSS:

#postajob {
-webkit-font-smoothing: antialiased;
.header {
background: $postajob_header_bg_color;
border-bottom: 1px solid $postajob_header_border_color;
height: auto;
padding-bottom: 20px;
h2 {
margin-top: 110px;
color: $postajob_header_text_color;
font-weight: 400;
font-size: 34px;
z-index: 100;
text-align: center;
@include max-sm {
margin-top: 95px;
font-size: 28px;
}
}
p {
font-weight: 300;
font-size: 17px;
color: $postajob_header_subtext_color;
z-index: 100;
text-align: center;
@include max-sm {
font-size: 14px;
}
}
.background-images {
width: 100%;
height: 50%;
&.img1 {
position: absolute;
background-repeat: no-repeat;
background-image: url('../../images/flat-icons/svg/paper-airplane.svg');
z-index: 3;
@include min-md {
background-size: 150px 150px;
top: 150px;
left: 80%;
}
@include max-md {
background-size: 100px 100px;
top: 180px;
left: 85%;
}
@include max-sm {
background-size: 40px 40px;
top: 180px;
left: 45%;
}
@include max-xs {
background-size: 40px 40px;
top: 180px;
left: 45%;
}
}
}
}
}

您可以通过调整片段大小来查看图像相对于标题的行为方式。然而,如您所见,这都是从将像素硬编码到样式表中。

我的问题是:无论分辨率或设备如何,如何让图像像第一个片段(全尺寸时)一样贴在页眉底部?

最佳答案

它不需要背景图片或网格系统。 Bootstrap 文档正确地指出始终是全宽的东西,那么您不需要网格系统。

演示:https://jsbin.com/gomoca/1/

https://jsbin.com/gomoca/1/edit?html,css,output

HTML:

 <section class="primary-page-header text-center">
<div class="container">
<h1>Title</h1>
<p>Text Goes Here</p>
<div class="page-header-img center-block">
<img src="http://placekitten.com/g/150" class="img-responsive img-circle" alt="" />
</div>
</div><!-- /.container -->
</section><!-- /.primary-page-header>

CSS:

.primary-page-header {
background: #f7f7f7;
border-bottom: 4px double #aaa;
padding-top: 5%;
}
.primary-page-header p {
padding-bottom: 2%;
}
.primary-page-header h1 {
font-size:24px;
}
.page-header-img img {
border:1px solid #aaa;
padding:3px;
background:#fff;
}
.page-header-img {
width: 50px;
height: 50px;
margin-bottom: -25px;
}

@media (min-width:600px) {
.page-header-img {
width: 100px;
height: 100px;
margin-bottom: -50px;
}
}
@media (min-width:768px) {
.page-header-img {
width: 150px;
height: 150px;
margin-bottom: -75px;
}
.primary-page-header h1 {
font-size:55px;
}
}

关于html - 重叠/粘贴背景图像以重叠 div 的边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27726352/

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