gpt4 book ai didi

html - 响应式布局包括 HTML5 视频

转载 作者:行者123 更新时间:2023-11-28 17:06:10 25 4
gpt4 key购买 nike

我正在为响应式布局而苦苦挣扎......

What I want to achieve在上图中,红色是 HTML5 视频,蓝色是图片。我正在使用 JavaScript 使 HTML5 视频响应 -//vjs.zencdn.net/4.12/video.js

但是无论我如何布局,Firefox 或 Chrome 和 IE 在图像 2 和 4 (Firefox) 或 5 (IE 和 Chrome) 下方有一条 1px 的线。

参见 jsfiddle.net代码在这里...

<div id="container">
<div id="col_left">
<img src="http://lorempixel.com/g/220/205/"/>
<img src="http://lorempixel.com/g/220/270/" class="has_top_margin" />
</div>
<div id="col_center">
<video id="example_video_1" class="video-js vjs-default-skin" poster="" data-setup='{"controls": false, "autoplay": true, "preload": "auto"}'>
<source src="http://www.quirksmode.org/html5/videos/big_buck_bunny.mp4" type="video/mp4" />
</video>
<img src="http://lorempixel.com/g/480/207/" class="has_top_margin" />
</div>
<div id="col_right">
<img src="http://lorempixel.com/g/220/205/" />
<img src="http://lorempixel.com/g/220/270/" class="has_top_margin" />
</div>
<div style="clear:both"></div>
</div>

任何人都可以建议代码来完成这项工作吗?我不介意合并图像 1/2 和 3/4 如果它更容易......但它必须响应并且必须填充高度。

编辑:更新Fiddle

最佳答案

是的,首先,尽量将 CSS 和 HTML 分开。内联 CSS 非常困惑,当您使用它时会导致不必要的问题。

The whole point of semantic HTML and CSS is to separate document structure and styling, so it just doesn’t make sense to go placing styling directly in the HTML document. Remember to always keep your styles in your stylesheet where they belong.

因此,您应该始终尝试在您的 <head> 中添加如下一行标签:

<link type="text/css" rel="stylesheet" href="/path/to/style.css">

对于页面本身,试试这个:

* {
color: white;
text-align:center;
}

#content, #sidebar_left, #sidebar_right {
height:500px;
}

#sr1, #sl1, #sr2, #sl2 {
height:100px;
background:blue;
}

#sr1, #sl1 {
height:30%;
margin: 10px;
}

#sr2, #sl2 {
height:70%;
margin: 10px;
}

#c1{
background:red;
height:50%;
margin:10px;
}

#c2 {
background:blue;
height:50%;
margin:10px;
}

#sidebar_left {
float:left;
width:20%;
}

#content {
width:60%;
float:left;
}

#sidebar_right {
float:left;
width:20%;
}
<div id="page">
<div id="sidebar_left">
<div id="sl1">Column 1</div>
<div id="sl2">Column 2</div>
</div>
<div id="content">
<div id="c1">Video</div>
<div id="c2">Column 5</div>
</div>
<div id="sidebar_right">
<div id="sr1">Column 3</div>
<div id="sr2">Column 4</div>
</div>

</div>

JSFiddle!:

Here's a jsfiddle so you can play with the width.

编辑:如果您正在使用 <img>标记,将以下内容添加到您的 CSS,您的图像底部将没有填充:

img {
display: block;
}

Fiddle

关于html - 响应式布局包括 HTML5 视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30302879/

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