HTML:如何将我的视频右对齐并在左侧放置文本?

标签 html css html5-video

我的 html 文件中有以下代码:

  <video 
     src="finalvid.mp4"
     preload="auto"
     width="320"             
     heigth="240"
     align="right"             
     controls
     loop>
  </video>

首先,我尝试将其右对齐。显然 align="right"部分不起作用(可能它不属于那里)。我正在搜索视频标签以放入 css 文件,但我没有找到任何东西。 其次,我想在视频的左边放一段话。基本上,要有两列,第一列(左)是文本,第二列(右)是视频。

最佳答案

将每一边包裹在一个 block 元素(例如 div、部分等)中,然后用一个“flex 容器”包裹它们,这是一个带有 display:flex 的元素。默认情况下, flex 容器会将其子容器排成一行。

演示

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0
}

.main {
  display: flex;
  justify-content: center;
  align-items: center;
}

.section {
  width: 50%;
  height: 100%;
}

video {
  width: 100%;
  height: 56.25%;
  margin-top: 21.875%;
}
<main class='main'>

  <section class='left section'>

    <p>But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the gre</p>

  </section>
  <section class='right section'>

    <video src='http://media6000.dropshots.com/photos/1381926/20170326/005611.mp4' controls></video>

  </section>

</main>

关于HTML:如何将我的视频右对齐并在左侧放置文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48022929/

相关文章:

javascript - 使用Jquery恢复视频(Html5视频元素)

javascript - 如何根据特定字符进行自动换行?

javascript - 如何根据单击哪个按钮进入页面来设置哪个选项卡处于事件状态

css - 是什么阻止了我的 CSS3 SVG 动画?

css - Font Awesome 5.11.2 不在 iFrame 中呈现,而是在主页上呈现

ios - 为什么苹果设备在自己的播放器中播放 html5 视频?

html - 滚动时修复表格标题

jquery - 在单选选择中显示 HTML 表格

html - 垂直对齐 <li> 中的 <span> 且高度未知

html5-video - 如何在播放时切换音轨