上面代码 图片位置布局如何实现,请画一个示例布局
时间: 2023-11-22 13:52:43 浏览: 38
以下是一个简单的示例布局,可以使用HTML和CSS实现:
```
<div class="container">
<div class="image">
<img src="example.jpg" alt="Example Image">
</div>
<div class="content">
<h2>Example Title</h2>
<p>Example description text.</p>
<button>Learn More</button>
</div>
</div>
```
CSS样式:
```
.container {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.image {
flex: 1;
margin-right: 20px;
}
.image img {
max-width: 100%;
}
.content {
flex: 1;
}
.content h2 {
font-size: 24px;
margin-bottom: 10px;
}
.content p {
font-size: 16px;
line-height: 1.5;
margin-bottom: 20px;
}
button {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
```
在这个示例布局中,图片和内容都被包含在一个名为“container”的div中。通过使用flexbox布局,我们可以轻松地将这两个元素并排放置,并使它们在水平方向上居中对齐。图片使用“flex: 1”属性来自动调整其大小以填充可用空间。内容部分同样使用“flex: 1”属性,以便它占据剩余的空间。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)