css - 将段落文本放在 youtube 视频旁边?
问题描述
任何人都知道如何放置一个
在 youtube 视频旁边添加标签,而不会在边框和视频之间垂直创建额外的行间距?就像我试图将文本放在第一个视频的右侧,但它不断在视频和显示视频的边框之间留出额外的空间。
<!DOCTYPE html
<html lang="en">
<meta charset="UTF-8">
<head>
<title>007 Nightfire | Videos</title>
</head>
<style>
.div1 {
background-color:#77BFC7;
text-align:center;
font-size:50px;
border:1px solid #77BFC7;
height:70px;
font-weight:bold;
}
body {
background-color:#00AAFF;
}
hr {
height:0px;
background-color:#000000;
border:solid;
}
</style>
<body>
<div class="div1">
Videos
</div>
<center>
<iframe width="520" height="300"
src="https://www.youtube.com/embed/7TVYA_o5Fsw" allowfullscreen style="position:relative; top:5px; right:360px;">
</iframe>
<br>
<br>
<hr>
<iframe width="520" height="300"
src="https://youtube.com/embed/XZMtPu35UT8" allowfullscreen style="position:relative; top:10px; left:350px;">
</iframe>
</body>
</html>
解决方案
您只需要一个具有内联样式的 div,并将文本浮动到右侧。我还建议将中心标签更改为 div,因为它不是推荐的 HTML5 居中方式。
.div1 {
background-color: #77BFC7;
text-align: center;
font-size: 50px;
border: 1px solid #77BFC7;
height: 70px;
font-weight: bold;
}
body {
background-color: #00AAFF;
}
hr {
height: 0px;
background-color: #000000;
border: solid;
}
<div class="div1">
Videos
</div>
<center>
<div style="display: inline-block;">
<iframe width="520" height="300" src="https://www.youtube.com/embed/7TVYA_o5Fsw" allowfullscreen style="position:relative; top:5px; right:360px;">
</iframe>
<p style="float: right">Text Content Here</p>
</div>
<br>
<br>
<hr>
<iframe width="520" height="300" src="https://youtube.com/embed/XZMtPu35UT8" allowfullscreen style="position:relative; top:10px; left:350px;">
</iframe>
</center>
推荐阅读
- flutter-listview - 如何在屏幕底部自动显示列表中的展开项目?
- benchmarking - 谷歌基准 state.PauseTiming() 和 state.ResumeTiming() 需要很长时间
- html - 水平对齐 3 个图像和 3 个文本列表,具有响应性
- angular - 在Angular中选择之前和之后获取下拉列表的值
- php - 注意:未定义索引:注册(尝试制作注册表时出错?)
- javascript - 这种方法似乎破坏了我的 react-native 代码
- image-processing - 使用不同格式的文档的最佳 OCR 方法以查找特定信息
- android - 如何根据特定条件在recyclerview中除一行之外的所有行的inActive或禁用onClick?
- android - RN:不兼容的 Android 库
- reactjs - 如何在日期格式的字段中写入日期?