核心属性
display: flex + justify-content: space-between + align-items: center 图片居中水平排列
border-image 图片和文字的动画边框效果
@media 根据不同的页面大小,图片呈现不同的布局方式
相关知识
CSS3 border-image详解、应用及jQuery插件
-
<base href="https://pics.codecolor.cn/graphic-novel/">
-
<div id="strip">
-
<figure id="panel1">
-
<img src="pleading-man.jpg" alt="A photograph of a man kneeling in a parking garage, pleading for his life">
-
<figcaption>“等等…”</figcaption>
-
</figure>
-
<img src="car-strip.jpg" alt id="panel2">
-
<figure id="panel3">
-
<img src="gunman.jpg" alt="A backlit photograph of a man holding a gun">
-
<figcaption>砰!!!</figcaption>
-
</figure>
-
</div>
-
#strip {
-
display: flex;
-
justify-content: space-between;
-
align-items: center;
-
max-width: 820px;
-
margin: 0 auto;
-
}
-
#strip img {
-
border-image: url(https://pics.codecolor.cn/graphic-novel/comic-frame.png) 22 16 16 22;
-
background: #000;
-
border-width: 12px;
-
border-style: solid;
-
}
-
#panel1 {
-
width: 40%;
-
position: relative;
-
}
-
#panel3 {
-
width: 35%;
-
position: relative;
-
}
-
#panel1 img, #panel3 img {
-
width: 100%;
-
}
-
#strip figcaption {
-
position: absolute;
-
top: 2rem;
-
right: -2rem;
-
padding: 1rem;
-
background: #fff;
-
background-clip: padding-box;
-
font-size: 1.2rem;
-
font-family: Comic Sans MS, Comic Sans, cursive;
-
border-image: url(https://pics.codecolor.cn/graphic-novel/lettering-frame.png) 11 10 14 12;
-
border-width: 6px;
-
border-style: solid;
-
}
-
#panel1 figcaption {
-
letter-spacing: .3rem;
-
top: 1rem;
-
right: -4rem;
-
}
-
#panel3 figcaption {
-
left: -2rem;
-
width: 4rem;
-
font-style: italic;
-
}
-
@media screen and (max-width: 60rem) {
-
#panel2 {
-
display: none;
-
}
-
#strip img {
-
width: 100%;
-
}
-
#panel1 figcaption {
-
top: -1rem;
-
}
-
}
-
@media screen and (max-width: 50rem) {
-
#panel1 figcaption {
-
top: 10rem;
-
}
-
}
-
@media screen and (max-width: 30rem) {
-
#strip {
-
flex-direction: column;
-
}
-
#panel1 {
-
order: 3;
-
}
-
#panel1,#panel3 {
-
width: 60%;
-
}
-
#panel3 {
-
align-self: flex-end;
-
}
-
#panel3 figcaption {
-
display: none;
-
}
-
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- CSS实现平行四边形布局效果
- css经典布局系列三——三列布局(圣杯布局、双飞翼布局)
- 四种方法实现──三栏布局(圣杯布局、双飞翼布局)
- 浅谈CSS三栏布局(包括双飞翼布局和圣杯布局)
- css经典布局——圣杯布局
- CSS布局基础——(三栏布局)
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。