html - 如何对齐图像旁边的垂直按钮?

标签 html css

<分区>


想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post .

关闭 6 年前

请帮我对齐按钮旁边的图像。我还想让按钮彼此重叠,但在图像旁边

.body{
  background-color:#dbdbdb;
}
button{
  width:200px;
  height:60px;
  margin-right:10px;
 
}
</div>
<div class="body">
  <table>
    <tr>
      <td><img id="business"src="http://fullhdpictures.com/wp-content/uploads/2016/08/Business-People-Photos-HD.jpg"/></td>
      <td> <button id="plan" type="button">PLANNING</button></td>
      <td> <button id="strat" type="button">STRATEGY</button></td>
      <td> <button id="res" type="button">RESULTS</button></td>
    </tr>
  </table>
  
</div>

enter image description here

最佳答案

使用flexbox,比table更少的标记,更好的灵 active 和语义更正确

.body {
  display: flex;
}
.body > div {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

button {
  width: 200px;
  height: 60px;
  margin-right: 10px;
}


/* for demo purpose I made image smaller so one can see the layout */
.body > img {
  display: block;
  width: 420px;
  height: 276px;
}
<div class="body">
  <img id="business" src="http://fullhdpictures.com/wp-content/uploads/2016/08/Business-People-Photos-HD.jpg" />
  <div>
    <button id="plan" type="button">PLANNING</button>
    <button id="strat" type="button">STRATEGY</button>
    <button id="res" type="button">RESULTS</button>
  </div>
</div>

关于html - 如何对齐图像旁边的垂直按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40346890/

上一篇:jquery - 如何在 Bootstrap 导航中的移动设备上显示菜单图标?

下一篇:html - 鼠标移动时文字消失

相关文章:

css - 我如何使用 flexbox 实现它?

html - 网格布局css中的按钮

javascript - 在 javascript 上打开并读取类型 ='file'

html - 如何创建粘性页脚 - 另一种粘性?

html - flex 盒列内的 flex 盒行

javascript - 具有固定 img 位置的 Superslides.js

javascript - 单击选项卡时如何更改占位符文本

html - 网格自动流 : dense makes element width really small

javascript - Safari 6.1 HTML5 视频在内容后面闪烁

javascript - nth-child 选择器不适用于手机上属于 JavaScript 的 Tingle.js 类