html - 使 div 向左而不是向右增长

标签 html css

div 应该向左生长,然而,它现在做的恰恰相反。

顺便说一句,margin-left 和 top 是必需的。

展示问题的快速 gif:https://gyazo.com/ce51c504698395c26cffefb9b74e7e3e

html, body {
  width: 100%;
  height: 100%;
}

#a {
  width: 50%;
  height: 100%;
  border: 1px solid black;
}

#img-wrapper {
  margin-left: 10%;
  margin-top: 20%;
  width: 50%;
  position: relative;
  border: 1px solid red;
}

img {
  width: 100%;
}
<div id="a">
  <div id="img-wrapper">
   <img src="https://s3.amazonaws.com/cdn-origin-etr.akc.org/wp-content/uploads/2017/11/12225358/Pug-On-White-01.jpg" alt="">
</div>
</div>

最佳答案

试试这个:-

#a {
    width: 70%;
    height: 100%;
    border: 1px solid black;
    position: relative;
}
#img-wrapper {
    width: 40%;
    position: absolute;
    bottom: 0;
    right: 0;
    border: 1px solid red;
}

关于html - 使 div 向左而不是向右增长,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55182515/

相关文章:

javascript - React js 状态管理

css - 根据 Google 优化 CSS 交付

php - 如何在 php 中包含 css 文件以隐藏文件夹结构?

php - 如何在mysql连接失败时打开缓存?

html - 元素符号内缩进 <li>

javascript - 如何随机分配一个网页图标?

html - 我怎样才能去除云和边界之间的空白区域?

javascript - 强制在伪元素上不换行(:after)

javascript - 仅当单词对于整个句子来说太长时才使用连字符

html - 如何制作透明箭头?