【发布时间】:2017-05-08 01:03:41
【问题描述】:
【问题讨论】:
-
比这更具体!添加到目前为止您所做的代码。
【问题讨论】:
【讨论】:
width:calc((100% - 50px) / 2); 让侧面 div 具有相同的宽度(例如:jsfiddle.net/Lphf2hwz/1)-50px 是演示中图像的宽度
将图片放入div并使用伪元素
body {
width: 100vw;
height: 100vh;
background: rgb(141, 0, 0);
margin: 0;
display: flex;
align-items: center;
justify-content: center;
}
.image-container {
width: 100vw;
height: 50vh;
background: red;
display: flex;
}
.image-container:before,
.image-container:after {
content: "";
display: block;
width: 25%;
height: 100%;
background: yellow;
}
.image {
width: 50%;
height: 100%;
}
<div class="image-container">
<img class="image" src="https://upload.wikimedia.org/wikipedia/commons/4/4f/World_topic_image_Satellite_image.jpg">
</div>
【讨论】:
您的要求应该从下面这张图片开始的地方开始。你可以修改它以获得你需要的布局
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<style type="text/css">
#container{width:100%;height:100%; background-color: white;}
#left{float:left;width:100px;height:100px;background-color: yellow;}
#right{float:right;width:100px;height:100px;background-color: orange;}
#center{margin:0 auto;width:100px;height:100px;background-color: violet;}
</style>
<div id="container">
<div id="left">Your Left Div</div>
<div id="right">Your Right Div</div>
<div id="center">Image Goes Here</div>
</div>
</body>
</html>
【讨论】: