Html 在Div旁边写字

Html 在Div旁边写字,html,css,Html,Css,我试着让两个div(一个是嵌入了YouTube视频的图像,另一个是文本)并排放置。我通常使用float:left规则,但是对于图像上的视频来说,CSS/HTML组合更为棘手 我该怎么做呢 我的代码: .backgroundimage{ 位置:相对位置; 顶部:70像素; 右:390px; 浮动:左; } .Youtube{ 位置:绝对位置; 左:280px; 底部:46px; } 嗨,这是一些测试文本 在页面上使用引导。 在站点上获取引导CND 现在试试这个 <div class="

我试着让两个div(一个是嵌入了YouTube视频的图像,另一个是文本)并排放置。我通常使用
float:left规则,但是对于图像上的视频来说,CSS/HTML组合更为棘手

我该怎么做呢

我的代码:

.backgroundimage{
位置:相对位置;
顶部:70像素;
右:390px;
浮动:左;
}
.Youtube{
位置:绝对位置;
左:280px;
底部:46px;
}

嗨,这是一些测试文本


在页面上使用引导。 在站点上获取引导CND

现在试试这个

<div class="container">
    <div class="row">
        <div class="col-sm-6">
           <img src="http://truespeed.ca/wp-content/uploads/2016/06/tvscreen.png" alt="null" />
           <iframe class="Youtube" width="479" height="269" src="https://www.youtube.com/embed/6ydYvG52K-E" frameborder="0" allowfullscreen></iframe>
        </div>
        <div class="col-sm-6">
            <p>Hi, this is some test text!</p>
        </div>
    </div>
</div>

嗨,这是一些测试文本


在页面上使用引导。 在站点上获取引导CND

现在试试这个

<div class="container">
    <div class="row">
        <div class="col-sm-6">
           <img src="http://truespeed.ca/wp-content/uploads/2016/06/tvscreen.png" alt="null" />
           <iframe class="Youtube" width="479" height="269" src="https://www.youtube.com/embed/6ydYvG52K-E" frameborder="0" allowfullscreen></iframe>
        </div>
        <div class="col-sm-6">
            <p>Hi, this is some test text!</p>
        </div>
    </div>
</div>

嗨,这是一些测试文本


使用
显示:内联块
而不是
浮动:左

.backgroundimage{
位置:相对位置;
顶部:70像素;
右:390px;
显示:内联块;
}
.Youtube{
位置:绝对位置;
左:500px;
底部:46px;
}

嗨,这是一些测试文本


使用
显示:内联块
而不是
浮动:左

.backgroundimage{
位置:相对位置;
顶部:70像素;
右:390px;
显示:内联块;
}
.Youtube{
位置:绝对位置;
左:500px;
底部:46px;
}

嗨,这是一些测试文本

查看它是否正在编写

因此,我认为可以使用CSS属性在背景中显示图像,而不是使用
。CSS代码:

.backgroundimage {
  position: relative;
  background: url("http://truespeed.ca/wp-content/uploads/2016/06/tvscreen.png") no-repeat;
  height:329px;
}
.Youtube {
  position: absolute;
  left:10px;
  top:10px;
} 
p{
  position: absolute;
  right:0;
  width:140px;
}
已编辑检查响应文本

以查看其是否正在编写

因此,我认为可以使用CSS属性在背景中显示图像,而不是使用
。CSS代码:

.backgroundimage {
  position: relative;
  background: url("http://truespeed.ca/wp-content/uploads/2016/06/tvscreen.png") no-repeat;
  height:329px;
}
.Youtube {
  position: absolute;
  left:10px;
  top:10px;
} 
p{
  position: absolute;
  right:0;
  width:140px;
}

已编辑检查是否有响应文本

我在您的HTML代码中没有看到任何文本。我向其中添加了一些文本。谢谢你告诉我!请检查我发布的答案中的代码。我在你的HTML代码中没有看到任何文本。我在其中添加了一些文本。谢谢你告诉我!请检查我发布的答案中的代码。对不起,它不起作用。我所有的字符都是垂直的,一直向下到页脚。只需注释或删除行:
width:505px来自
.backgroundimage
。我在发布链接之前忘了更新小提琴。对不起,它不工作。我所有的字符都是垂直的,一直向下到页脚。只需注释或删除行:
width:505px来自
.backgroundimage
。在发布链接之前,我忘了更新小提琴。