html - 图片改变div位置

标签 html css

我正在尝试使两列由圆形页面分隔或在圆形页面内第二列应该有这样的图像:

<div class="step second">
  <div id="upload-img"></div>
  <div id="sperator">
    <div class="circle" id="or"><p class="number" style="padding-left:25%;">or</div>
  </div>
  <div id="default-img">
    <img src=""/>
  </div>
</div>

但由于某种原因,#sperator div 的位置随图像而变化我的 css 有点长所以这里有一个 js fiddle 来进行更多解释:here

如您所见,图像应该与另一个 div 在同一行,但它改变了分隔符 div 的位置

最佳答案

您应该重新检查您的 html 标签。确保每个标签正确关闭

这是你的CSS:

.step{
    position:relative;
    width:500px;
    height:250px;
    border:1px solid black;
}
#upload-img{
    position:absolute;
    left:0;
    top:0;
    width:50%;
    height:100%
}

#default-img{
    position:absolute;
    right:0;
    top:0;
    width:50%;
    height:100%
    }
#upload-img img, #default-img img{
    max-width:100%;
    max-height:100%;    
}

#sperator .circle{
    position:absolute;
    height:66px;
    width:66px;
    background-color:black;
    top:50%;
    left:50%;
    margin:-33px auto auto -33px;
    border-radius:50%;
    z-index:100;
    text-align:center;
}
#sperator .circle p{
  font-size:35px;
  font-family:futura-book;
  color:white;    
  padding:0 !important;
  margin:0;
  line-height:60px;
}
.step::after{
    content:'';
    height:100%;
    width:3px;
    left:50%;
    margin-left:-2px;    
    z-index:90;
    position:absolute;
    background-color:black;
}

potition:relative 将是一个将“锁定”其中每个 potition:absolute 的区域。

您可以使用 position:relative 作为父 divposition:absolute 作为子 div

关于html - 图片改变div位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28067365/

相关文章:

css - :hover with css sprites z-index problem

html - 如何在执行 float :right. 后垂直显示列表 How can I display the list vertically after float:right

html - 使用 :not with :active (CSS)

javascript - 如何指定一个样式不被JS中指定的样式覆盖

php - 为什么 str 替换仅在第一个匹配中起作用?

html - 尝试解析 CSS :nth-child formula with elements with a gallery

javascript - 为什么这个点击事件触发了错误的元素?”

html - 缩放和分辨率

html - 在这种情况下如何正确使用背景位置百分比?

html - 右边的CSS图像和文字