html - 如何正确对齐此 CSS

标签 html css alignment

所以我的页面是here正如您在中间看到的那样,我正在尝试(未成功)将两个图像放入灰色框中......每一侧一个。这是我的 html

  <div class="top_center_image">
     <div class="left_image">
     </div>
     <div class="right_image">
    </div>
  </div>

这是我的 CSS

.top_center_image{
    background: url("../image/TopBox.png") no-repeat;
  height: 179px;
  margin-left: 5px;
  width: 649px;
}
.left_image{
    background: url('../image/DwightWorldVideoleft.png') top left no-repeat;
    width: 296px;
  height:152px;
    margin-left:11px;
    float:left;
}

.right_image{
  background: url("../image/AMWimage.png") no-repeat scroll left top transparent;
   height: 152px;
   margin-left: 11px;
   width: 311px;
    float:right;
}

有没有一种更简单、更好的方法来排列所有这些......提前致谢

最佳答案

以下内容对我有用......

.right_image {
background: url("../image/AMWimage.png") no-repeat scroll left top transparent;
float: right;
height: 152px;
margin-right: 12px;
margin-top: 12px;
width: 311px;

}

.left_image {
background: url("../image/DwightWorldVideoleft.png") no-repeat scroll left top transparent;
float: left;
height: 152px;
margin-left: 11px;
margin-top: 12px;
width: 296px;

}

我为两者都添加了 margin-top 规则。我从右侧图像中删除了 margin-left,并在其位置添加了 margin-right。

关于html - 如何正确对齐此 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5843155/

相关文章:

css - 我希望同一行上的 P 标记文本彼此相邻

c++ - std::hardware_constructive_interference_size 有用吗?

html - 我的标题中有一个按钮,但在只有 1 个按钮后仍然显示 2 个按钮

javascript - 表单提交转至 Javascript - 并保持在同一页面上

jquery - 如何使用 css3 flexbox 和 jquery 创建文件上传按钮?

css - SCSS 媒体查询宽高比不起作用

c++ - std::aligned_storage 的分配目标(堆栈或堆?)

html - 如何为带有标签名称的标签添加 css?

html - 如何显示 Bootstrap 4 导航栏链接并排并向右浮动?

javascript - 按下/释放时更改按钮的状态