html实现左边视频,右边文字介绍的效果,并且是响应式布局,视频也出链接代码
时间: 2024-03-03 08:51:48 浏览: 139
可以使用HTML和CSS实现左侧视频,右侧文字介绍的效果,并且设置为响应式布局,即在不同设备上具有不同的布局和尺寸。下面是一个简单的示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>左侧视频,右侧文字介绍</title>
<style>
.container {
display: flex;
flex-wrap: wrap;
}
.video {
flex-basis: 100%;
height: 0;
padding-bottom: 56.25%; /* 16:9 比例 */
position: relative;
}
.video iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.description {
flex-basis: calc(100% - 400px);
padding: 20px;
box-sizing: border-box;
}
@media (min-width: 768px) {
.video {
flex-basis: 400px;
height: auto;
padding-bottom: 0;
}
.description {
flex-basis: calc(100% - 400px);
padding: 40px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
<div class="description">
<h1>视频介绍</h1>
<p>这里是视频的文字介绍,可以根据需要添加更多内容。</p>
</div>
</div>
</body>
</html>
```
在这个示例中,使用了flex布局来实现左侧视频和右侧文字介绍的排列。设置视频容器的宽度为100%,高度为0,使用padding-bottom来实现16:9的宽高比例。同时,将视频的position设置为relative,iframe的position设置为absolute,并且设置top、left、width和height属性为100%来使其占满整个容器。
在@media查询中,设置响应式布局,当设备宽度大于等于768像素时,将视频容器的宽度设置为固定的400像素,同时取消height和padding-bottom属性。这样可以保证在较小的设备上,视频和文字介绍能够自适应布局,而在较大的设备上,视频容器的宽度固定为400像素,文字介绍也会更加宽敞。
代码中的视频链接是一个Rick Astley的视频,可以根据需要替换为其他视频链接。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pptx](https://img-home.csdnimg.cn/images/20241231044947.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)