html - 并排响应图像和文本

标签 html css

我正在尝试制作 2 列:

第一个是占页面 50% 的图像,另一个是占页面剩余 50% 的文本框。没有边距。

有没有可能有这样的响应式的东西?我正在努力使背景颜色与图像对齐。

.imagebox {
  width: 50%;
  float: left;
}

.textbox {
  width: 50%;
  float: right;
  text-align: center;
  padding-top: 20px;
  background-color: #666;
  color: #fff;
}
   
<div class="imagebox">
<img src="http://www.mokshasoulyoga.com/wp-content/uploads/2017/04/5.png" width="100%" height="auto" />

</div>


<div class="textbox">

  <h2>Title Here</h2>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
  <a href="#">Read More</a>

</div>

最佳答案

这里的前半部分是一个 <img>第二个是 <textbox>

https://jsfiddle.net/b8ow0noy/1/

链接中的代码在这里

<div style="width: 50%; float:left">
<img src="https://www.w3schools.com/css/trolltunga.jpg">
</div>

<div style="width: 50%; float:right">
<textbox>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   #right content in there<br>
   </textbox>
</div>

CSS:

div{
  margins:0 px;
  overflow:hidden;
}

关于html - 并排响应图像和文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43320353/

相关文章:

html - 实现 'sticky footer' 时浏览器之间的行为不一致

css - Angular 2动画高度属性 - 绑定(bind)时间

javascript - <ul> 和 <li> - 具有交替行颜色的表格

html - -webkit-linear-gradient 在 Chrome 和 Safari 上运行良好,但在 Firefox 上不起作用

html - 图片有时加载不出来

javascript - 在JS中引用时如何让Form元素正确工作?

javascript - 函数不接受回调

javascript - AngularJS - 获取对象值的指令

javascript - Logo 和菜单未对齐

css3 动画,淡入为下移?