相关疑难解决方法(0)

将div设置为其兄弟宽度

我正在寻找以下的CSS解决方案: -

<div style="display:inline;">
     <div>The content of this div is dynamically created but will always be wider than
              the below div. 
     </div>
     <div> Need this div to have the same width as the above div.
     </div>
</div>
Run Code Online (Sandbox Code Playgroud)

包装器div具有内联显示并按预期工作,两个子div都具有动态生成的内容.我需要底部采取前一个兄弟的宽度.

非常感谢您提前提出的任何建议.

html css html5 css3

26
推荐指数
4
解决办法
2万
查看次数

如何将文字宽度与动态尺寸图像的宽度匹配?

请参阅以下代码笔:https ://codepen.io/allen-houng/pen/XGMjMr ? editors = 1100#0

<div>
  <img src="https://res.cloudinary.com/djcpf0lmv/image/upload/v1549372650/Templates/yoga.jpg" data-radium="true" style=";">
  <div class="description">
    Fusce consequat. Nulla nisl. Nunc nisl. Duis bibendum, felis sed interdum   venenatis, turpis enim blandit mi, in porttitor pede justo eu massa. Donec dapibus. Duis at velit eu est congue elementum.
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我有一个有两个子div的父div-一个图像和一个描述。我正在根据视口高度调整图像的大小,这意味着宽度将是动态的且响应迅速。如何在.description不使用JavaScript的情况下调整相应的同级div的大小以匹配图像的宽度?

换句话说,我该如何处理: 在此处输入图片说明

到这个: 在此处输入图片说明

css

2
推荐指数
1
解决办法
129
查看次数

标签 统计

css ×2

css3 ×1

html ×1

html5 ×1