并排的两个 div - 流体显示 - Two divs side by side - Fluid display

问题:

I am trying to place two divs side by side and using the following CSS for it.我正在尝试并排放置两个 div 并为其使用以下 CSS。

#left {
  float: left;
  width: 65%;
  overflow: hidden;
}

#right {
  overflow: hidden;
}

The HTML is simple, two left and right div in a wrapper div. HTML 很简单,左右两个 div 在一个包装 div 中。

<div id="wrapper">
  <div id="left">Left side div</div>
  <div id="right">Right side div</div>
</div>

I have tried so many times to search for a better way on StackOverflow and other sites too, But couldn't find the exact help.我已经多次尝试在 StackOverflow 和其他网站上寻找更好的方法,但找不到确切的帮助。

So, the code works fine at first glance.因此,乍一看,该代码运行良好。 Problem is this, that the left div gets padding/margin automatically as I increase width in (%).问题是,当我以 (%) 增加宽度时,左边的 div 会自动获得填充/边距。 So, at 65% width, the left div is having some padding or margin and is not perfectly aligned with the right div, I tried to padding/margin 0 but no luck.因此,在 65% 宽度时,左侧 div 有一些填充或边距,并且与右侧 div 不完全对齐,我尝试将填充/边距设为 0,但没有成功。 Secondly, If I zoom in the page, the right div slides below the left div, Its like not fluid display.其次,如果我放大页面,右边的div滑到左边的div下面,就像不是流体显示一样。

Note: I am sorry, I have searched a lot.注意:对不起,我已经搜索了很多。 This question has been asked many times but those answers aren't helping me.这个问题已被问过很多次,但这些答案对我没有帮助。 I have explained what the problem is in my case.我已经解释了我的情况是什么问题。

I hope there is a fix for that.我希望有一个解决办法。

Thank you.谢谢你。

EDIT: Sorry, me HTML problem, There were two "box" divs in both left and right sides, They had padding in %, So left side showed more padding because of greater width.编辑:对不起,我的 HTML 问题,左侧和右侧都有两个“框”div,它们以 % 填充,因此左侧显示更多的填充,因为宽度更大。 Sorry, The above CSS works perfect, its fluid display and fixed, Sorry for asking the wrong question...抱歉,上面的 CSS 效果很好,它的流畅显示和修复,抱歉问错了问题......


解决方案:

参考一: https://stackoom.com/question/1AF7u
参考二: Two divs side by side - Fluid display
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章