Blogger Information
Blog 13
fans 0
comment 7
visits 17260
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
列间隙的两种设置方法和等高列实现
ccc9112020
Original
3368 people have browsed it
  1. 列间隙的两种设置方案
    两列或者是多列加上边距后累计宽度如果超过父容器宽度会导致换行,从而使得布局不符合预期。列间隙设置方法包括计算边距设置和通过修改box-sizing属性设置。两种方法都可以实现设置边距的目标。计算边距可以是百分比也可以是具体em值,因为css的calc(x - y)可以计算属性值,注意加减号两侧必须加空格否则无效。计算边距可以用margin或者是padding.box-sizing设置省去了加减边距,但是边距只能够是padding,因为margin不算在width中。
    下面分别演示两种设置方法。
    html代码:

    1. <header>PHP中文网</header>
    2. <div class="container">
    3. <aside class="left">菜单选项</aside>
    4. <main>栏目分类</main>
    5. <aside class="right">热门课程</aside>
    6. </div>
    7. <footer><p>底部</p></footer>
    • 百分比设置列间隙css代码

      1. /**
      2. 列间隙设置不当会导致元素分行显示,破坏页面结构.
      3. 通过margin=100%-left_element.width-right_element.width实现.
      4. width可以在css中用总体百分比或者是用calc(element.width - margin)计算.
      5. calc中减号两侧必须有空格,否则无效.
      6. **/
      7. * {
      8. margin: 0;
      9. padding: 0;
      10. /* outline: 1px dashed lightcoral; */
      11. /* w3c标准默认盒模型是content-box,无需显式声明,width不包括border和padding */
      12. box-sizing: content-box;
      13. }
      14. /* css中尽可能避免用标签选择器,以实现样式复用,但是也不是不可以用 */
      15. header {
      16. width: 100%;
      17. height: 5em;
      18. background-color: lightblue;
      19. text-align: center;
      20. /* border-box的width和height包括border和padding,在设计垂直居中的时候可以直接根据元素宽高设置 */
      21. box-sizing: border-box;
      22. padding-top: 1.5em;
      23. }
      24. .container {
      25. /* 父元素只设置了min-height,没有设置height,所以百分比没有效果 */
      26. min-height: 80vh;
      27. outline: 1px dashed red;
      28. /* 子元素的height过大会导致溢出。而overflow(overflow-x,overflow-y)可以设置溢出的处理方式,包括visible,hidden,auto(溢出时自动出现滚动条),scroll多种 */
      29. overflow: auto;
      30. /* 垂直居中设置方法之一:父元素position设置为非static,子元素设置绝对定位可以实现垂直居中,但是float后的子元素不可以? */
      31. /* position: relative; */
      32. }
      33. .container > .left {
      34. width: 19%;
      35. height: 100%;
      36. height: 50%;
      37. margin-right: 1%;
      38. /* aside和main都是html5语义化标签,默认块元素,可以用float改成行内块元素,或者是用flex设置为行内块元素 */
      39. float: left;
      40. background-color: lightgoldenrodyellow;
      41. /* text-align文字水平居中 */
      42. text-align: center;
      43. }
      44. .container > main {
      45. width: 60%;
      46. /* height设置过大,可以通过父元素的overflow予以处理,包括显示,隐藏,滚动条,自动各种选项 */
      47. height: 50em;
      48. /* float:left把块元素声明为行内块元素,可以在一行并排显示 */
      49. float: left;
      50. background-color: lightcoral;
      51. text-align: center;
      52. /* float后不能够通过绝对定位来实现垂直居中?,但是已知宽高,实现垂直居中是很简单的 */
      53. /* position: absolute;
      54. top: 0;
      55. bottom: 0;
      56. left: 0;
      57. right: 0;
      58. margin: auto; */
      59. /* 用border-box确定上下padding,实现垂直居中 */
      60. box-sizing: border-box;
      61. padding-top: calc((50em - 1em) / 2);
      62. }
      63. .container > .right {
      64. width: calc(19% - 1em);
      65. height: 70vh;
      66. /* em设置margin可以使得在不同大小的窗口中margin保持一致,随元素字号大小而改变 */
      67. margin-left: 1em;
      68. float: left;
      69. background-color: lightgoldenrodyellow;
      70. display: flex;
      71. /* flex下text-align不生效?我几次都不成功。我看到很多例子是可以的。目前还不了解具体原因,因为我的学习还没有到flex,虽然讲课已经过了。用align-items加justify-content可以 */
      72. /* text-align: center; */
      73. align-items: center;
      74. justify-content: center;
      75. }
      76. footer {
      77. position: fixed;
      78. width: 100%;
      79. height: calc(20vh - 5em);
      80. background-color: #0752b5;
      81. color: white;
      82. }
      83. footer > p {
      84. /* 绝对定位实现垂直居中,父元素body的position不可以是static,但是无法实现p里面的文字居中 */
      85. width: 50px;
      86. height: 50px;
      87. position: absolute;
      88. top: 0;
      89. right: 0;
      90. bottom: 0;
      91. left: 0;
      92. margin: auto;
      93. }
      94. /* line-height等于父元素高度,加上vertical-align:center,可以实现垂直居中 */
      95. /* text-align:center实现水平居中 */
      96. footer > p {
      97. line-height: 50px;
      98. vertical-align: middle;
      99. text-align: center;
      100. }

      效果图:
      width计算设置列间隙

    • box-sizing设置列间隙

      1. /* content-box(W3C盒子)的width=内容宽度,不论是padding,margin,还是border都不在width里面,在设置间隙的时候不能够控制布局 */
      2. /* border-box又称怪异盒子/IE盒子,width=内容宽度+padding+border,这样可以利用padding设置列间隙,布局不会受影响 */
      3. /* margin在任何情况下都不计入盒子高度和宽度 */
      4. :root {
      5. box-sizing: border-box;
      6. }
      7. * {
      8. margin: 0;
      9. padding: 0;
      10. /* 把所有元素设为border-box,padding和border都在width内,在利用padding设置列间隙 */
      11. box-sizing: inherit;
      12. }
      13. header,
      14. footer {
      15. /* line-height和height设置一样,再通过 vertical-align 可以设置垂直居中,text-align 设置水平居中 */
      16. width: 100%;
      17. height: 10vh;
      18. background-color: lightblue;
      19. line-height: 10vh;
      20. text-align: center;
      21. vertical-align: middle;
      22. }
      23. .container {
      24. width: 100%;
      25. height: 80vh;
      26. outline: 1px dashed red;
      27. }
      28. .container > .left {
      29. float: left;
      30. width: 20%;
      31. height: 100%;
      32. background-color: blanchedalmond;
      33. padding-right: 1%;
      34. /* padding默认填充内容的background,通过background-clip:content-box可以设置无背景 */
      35. background-clip: content-box;
      36. border: 1px solid seagreen;
      37. }
      38. .container > main {
      39. float: left;
      40. width: 60%;
      41. height: 100%;
      42. background-color: burlywood;
      43. border: 1px blue solid;
      44. }
      45. .container > .right {
      46. float: left;
      47. width: 20%;
      48. height: 100%;
      49. padding-left: 1em;
      50. background-clip: content-box;
      51. background-color: cadetblue;
      52. border: 1px black solid;
      53. }

      效果图:
      box-sizing计算列间隙

  1. 等高列的表格实现
    等高列可以用flex和表格实现,还可以用grid实现,还可以用min-height实现。
    因为时间关系,我拉下的课程和作业比较多,所以本来想做一个比较完整的页面,比较一下各大门户(其实其他论坛也类似)的不同风格和国外主流门户的风格,但是最后放弃。只能够简单做一个效果。期待后续跟上课程。
    虽然只是简单页面,做起来也很吃力。时间太多了。所以说一个项目不能够奢求太大而全,而且一个项目需要和小伙伴们合作才可以。

    1. <header>
    2. <h1>四大门户热点新闻</h1>
    3. </header>
    4. <!-- wrapper用于包裹表格实现负margin -->
    5. <div class="wrapper">
    6. <div class="container">
    7. <div class="locality">
    8. <h2>国内四大门户</h2>
    9. <p>
    10. <b style="color: red">NOTE:</b><br />
    11. <span
    12. >内容和链接全部来自于新浪首页新闻,并不是真实各大网站(因为时间有限,计划严重缩水),特此声明</span
    13. >
    14. </p>
    15. </div>
    16. <!-- 下面展示单个网站内容 -->
    17. <!-- 新浪 -->
    18. <div class="website-container">
    19. <div class="brand">
    20. <a class="sina"></a>
    21. </div>
    22. <div class="website-hots">
    23. <a
    24. href="https://news.sina.com.cn/gov/2020-10-30/doc-iiznezxr8879299.shtml"
    25. >中部崛起势头强劲再上新台阶</a
    26. >
    27. <a
    28. href="https://news.sina.com.cn/o/2020-10-30/doc-iiznezxr8999512.shtml"
    29. >钟南山带来好消息!</a
    30. ><a
    31. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8602807.shtml"
    32. >精彩了!美国大媒体猛撕“毒媒”《苹果日报》</a
    33. ><a
    34. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042791.shtml"
    35. >美大使抹黑中国5G不成,跟网友打起嘴仗……</a
    36. >
    37. <a
    38. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042801.shtml"
    39. >马英九:无耻、无耻、无耻,蔡英文一言不发……</a
    40. >
    41. <a
    42. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8615055.shtml"
    43. >傅高义警告蔡英文:两岸问题不会留到下一代解决!</a
    44. >
    45. <a
    46. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9043090.shtml"
    47. >日媒:防备台海冲突 日本酝酿举行35年来最大规模演习</a
    48. >
    49. <a
    50. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr8984997.shtml"
    51. >改变对美国巴西大豆依赖 中国又有新动作</a
    52. >
    53. <a
    54. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8566589.shtml"
    55. >澳前驻华大使:都怪中国,把我们“好名声”搞臭了</a
    56. ><a
    57. href="https://news.sina.com.cn/w/2020-10-30/doc-iiznezxr9018883.shtml"
    58. >美国已经盯上了:这颗小行星估价为世界经济总量1万倍</a
    59. >
    60. <a
    61. href="https://finance.sina.com.cn/roll/2020-10-31/doc-iiznctkc8640320.shtml"
    62. >网信办集中整治手机浏览器 “华米OV”声明自查整改</a
    63. >
    64. </div>
    65. </div>
    66. <!-- 下面展示单个网站内容 -->
    67. <!-- 搜狐 -->
    68. <div class="website-container">
    69. <div class="brand">
    70. <a class="sohu"></a>
    71. </div>
    72. <div class="website-hots">
    73. <a
    74. href="https://news.sina.com.cn/gov/2020-10-30/doc-iiznezxr8879299.shtml"
    75. >中部崛起势头强劲再上新台阶</a
    76. >
    77. <a
    78. href="https://news.sina.com.cn/o/2020-10-30/doc-iiznezxr8999512.shtml"
    79. >钟南山带来好消息!</a
    80. ><a
    81. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8602807.shtml"
    82. >精彩了!美国大媒体猛撕“毒媒”《苹果日报》</a
    83. ><a
    84. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042791.shtml"
    85. >美大使抹黑中国5G不成,跟网友打起嘴仗……</a
    86. >
    87. <a
    88. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042801.shtml"
    89. >马英九:无耻、无耻、无耻,蔡英文一言不发……</a
    90. >
    91. <a
    92. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8615055.shtml"
    93. >傅高义警告蔡英文:两岸问题不会留到下一代解决!</a
    94. >
    95. <a
    96. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9043090.shtml"
    97. >日媒:防备台海冲突 日本酝酿举行35年来最大规模演习</a
    98. >
    99. <a
    100. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr8984997.shtml"
    101. >改变对美国巴西大豆依赖 中国又有新动作</a
    102. >
    103. <a
    104. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8566589.shtml"
    105. >澳前驻华大使:都怪中国,把我们“好名声”搞臭了</a
    106. ><a
    107. href="https://news.sina.com.cn/w/2020-10-30/doc-iiznezxr9018883.shtml"
    108. >美国已经盯上了:这颗小行星估价为世界经济总量1万倍</a
    109. >
    110. <a
    111. href="https://finance.sina.com.cn/roll/2020-10-31/doc-iiznctkc8640320.shtml"
    112. >网信办集中整治手机浏览器 “华米OV”声明自查整改</a
    113. >
    114. </div>
    115. </div>
    116. <!-- 下面展示单个网站内容 -->
    117. <!-- 网易 -->
    118. <div class="website-container">
    119. <div class="brand">
    120. <a class="netease"></a>
    121. </div>
    122. <div class="website-hots">
    123. <a
    124. href="https://news.sina.com.cn/gov/2020-10-30/doc-iiznezxr8879299.shtml"
    125. >中部崛起势头强劲再上新台阶</a
    126. >
    127. <a
    128. href="https://news.sina.com.cn/o/2020-10-30/doc-iiznezxr8999512.shtml"
    129. >钟南山带来好消息!</a
    130. ><a
    131. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8602807.shtml"
    132. >精彩了!美国大媒体猛撕“毒媒”《苹果日报》</a
    133. ><a
    134. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042791.shtml"
    135. >美大使抹黑中国5G不成,跟网友打起嘴仗……</a
    136. >
    137. <a
    138. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042801.shtml"
    139. >马英九:无耻、无耻、无耻,蔡英文一言不发……</a
    140. >
    141. <a
    142. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8615055.shtml"
    143. >傅高义警告蔡英文:两岸问题不会留到下一代解决!</a
    144. >
    145. <a
    146. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9043090.shtml"
    147. >日媒:防备台海冲突 日本酝酿举行35年来最大规模演习</a
    148. >
    149. <a
    150. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr8984997.shtml"
    151. >改变对美国巴西大豆依赖 中国又有新动作</a
    152. >
    153. <a
    154. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8566589.shtml"
    155. >澳前驻华大使:都怪中国,把我们“好名声”搞臭了</a
    156. ><a
    157. href="https://news.sina.com.cn/w/2020-10-30/doc-iiznezxr9018883.shtml"
    158. >美国已经盯上了:这颗小行星估价为世界经济总量1万倍</a
    159. >
    160. <a
    161. href="https://finance.sina.com.cn/roll/2020-10-31/doc-iiznctkc8640320.shtml"
    162. >网信办集中整治手机浏览器 “华米OV”声明自查整改</a
    163. >
    164. </div>
    165. </div>
    166. <!-- 下面展示单个网站内容 -->
    167. <!-- 腾讯 -->
    168. <div class="website-container">
    169. <div class="brand">
    170. <a class="tencent"></a>
    171. </div>
    172. <div class="website-hots">
    173. <a
    174. href="https://news.sina.com.cn/gov/2020-10-30/doc-iiznezxr8879299.shtml"
    175. >中部崛起势头强劲再上新台阶</a
    176. >
    177. <a
    178. href="https://news.sina.com.cn/o/2020-10-30/doc-iiznezxr8999512.shtml"
    179. >钟南山带来好消息!</a
    180. ><a
    181. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8602807.shtml"
    182. >精彩了!美国大媒体猛撕“毒媒”《苹果日报》</a
    183. ><a
    184. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042791.shtml"
    185. >美大使抹黑中国5G不成,跟网友打起嘴仗……</a
    186. >
    187. <a
    188. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9042801.shtml"
    189. >马英九:无耻、无耻、无耻,蔡英文一言不发……</a
    190. >
    191. <a
    192. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8615055.shtml"
    193. >傅高义警告蔡英文:两岸问题不会留到下一代解决!</a
    194. >
    195. <a
    196. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr9043090.shtml"
    197. >日媒:防备台海冲突 日本酝酿举行35年来最大规模演习</a
    198. >
    199. <a
    200. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznezxr8984997.shtml"
    201. >改变对美国巴西大豆依赖 中国又有新动作</a
    202. >
    203. <a
    204. href="https://news.sina.com.cn/c/2020-10-30/doc-iiznctkc8566589.shtml"
    205. >澳前驻华大使:都怪中国,把我们“好名声”搞臭了</a
    206. ><a
    207. href="https://news.sina.com.cn/w/2020-10-30/doc-iiznezxr9018883.shtml"
    208. >美国已经盯上了:这颗小行星估价为世界经济总量1万倍</a
    209. >
    210. <a
    211. href="https://finance.sina.com.cn/roll/2020-10-31/doc-iiznctkc8640320.shtml"
    212. >网信办集中整治手机浏览器 “华米OV”声明自查整改</a
    213. >
    214. </div>
    215. </div>
    216. <div class="score">评分<br />250</div>
    217. </div>
    218. </div>
    1. :root {
    2. font-size: 0.625em;
    3. box-sizing: border-box;
    4. }
    5. * {
    6. margin: 0;
    7. padding: 0;
    8. box-sizing: inherit;
    9. }
    10. body {
    11. font-size: 1.6rem;
    12. }
    13. header {
    14. height: 5em;
    15. text-align: center;
    16. line-height: 5em;
    17. background-color: khaki;
    18. font-family: "宋体";
    19. font-size: 1.6rem;
    20. color: lightcoral;
    21. }
    22. /* 以下实现国内四大门户内容展示的表格布局 */
    23. .container {
    24. display: table;
    25. width: 100%;
    26. /* 第一个是水平间距,第二个是垂直间距 */
    27. border-spacing: 2em 0;
    28. }
    29. .container > .locality,
    30. .container > .website-container,
    31. .container > .score {
    32. display: table-cell;
    33. }
    34. .container > .locality {
    35. width: 10%;
    36. padding: 1em;
    37. text-align: center;
    38. vertical-align: middle;
    39. }
    40. .container > .website-container {
    41. width: 20%;
    42. }
    43. .container > .score {
    44. width: 10%;
    45. text-align: center;
    46. vertical-align: middle;
    47. color: blue;
    48. padding: 1em;
    49. }
    50. /* 设置负外边距消除外部 */
    51. .wrapper {
    52. margin: 0 -2em;
    53. }
    54. /* 以下实现门户网站内容展示css */
    55. .container > .website-container > .brand {
    56. width: 100%;
    57. height: 6em;
    58. }
    59. .container > .website-container > .brand > a {
    60. display: block;
    61. position: relative;
    62. width: 15em;
    63. height: 5em;
    64. }
    65. .container > .website-container > .brand > .sina {
    66. background: url(http://i2.sinaimg.cn/dy/deco/2013/0329/logo/LOGO_1x.png)
    67. no-repeat center center;
    68. /* 背景图按宽高比例缩放 */
    69. background-size: contain;
    70. }
    71. .container > .website-container > .brand > .sohu {
    72. background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJEAAABfCAIAAABnWLKwAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAABTSSURBVHjaYvx7gWEUDC0AEEBMo0Ew5ABAAI3G2dADAAE0GmdDDwAE0GicDT0AEECjcTb0AEAAjcbZ0AMAATQaZ0MPAATQaJwNPQAQQKNxNvQAQACNxtnQAwABNBpnQw8ABNBonA09ABBAo3E29ABAAI3G2dADAAE0GmdDDwAE0GicDT0AEECjcTb0AEAAjcbZ0AMAATQaZ0MPAATQaJwNPQAQQKNxNvQAQACNxtnQAwABNBpnQw8ABNBonA09ABBAAxxnf/8xVPTyptfzf//BOJiD6cevQeQ8gACieZx9/8n47BVOW96+Z1q3m2P/SbaHz5gHbYRVT+A18BfZcoCdoMpDZ9jiK/hnr+aiqXsAAojmcRZeKOCcIHztLguy4JXbLGU9vOeusXKw/4eIcHH+v3GPZekWzqPn2P78Gfh46p3P7Z8tuHwrJ5AtJfb333+GGSu4cBUVtx6wHDzNlt3El1LDf/wC25SltI0zgABiobXn7zxiAfrqyi0WLWVoVJy4yJpcLfD7D8O9xyzLej5ABDnY/nfO5t59jB0cRv8qUr942P4cwDhbt4vj9XumjtncQGdY6P+eyACKmC/fGN+8Z9p+iB3IYGRkYGdj+POX4cQF1vPXWZH1+jvR1uUAAcRCnyCA1wfvPzFlNPADI0xR5m9T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Jggg==)
    73. no-repeat center center;
    74. /* 背景图按宽高比例缩放 */
    75. /* background-size: contain; */
    76. }
    77. /* 精灵图,我还不会处理,打字代替 */
    78. .container > .website-container > .brand > .netease::after {
    79. content: "网易";
    80. color: blue;
    81. font-size: 3em;
    82. font-style: italic;
    83. font-weight: bold;
    84. font-family: "楷体";
    85. letter-spacing: 0.3em;
    86. text-align: center;
    87. vertical-align: middle;
    88. position: absolute;
    89. top: 0.5em;
    90. left: 1em;
    91. background-color: lightblue;
    92. }
    93. .container > .website-container > .brand > .tencent {
    94. background: url(https://mat1.gtimg.com/pingjs/ext2020/qqindex2018/dist/img/qq_logo_2x.png)
    95. no-repeat center center;
    96. /* 背景图按宽高比例缩放 */
    97. background-size: 80%;
    98. }
    99. .container > .website-container > .website-hots {
    100. width: 100%;
    101. padding: 1em;
    102. border-radius: 0.5em;
    103. border: 2px solid coral;
    104. }
    105. /* a标签四个伪类::link,:visited,:hover,:active,次序不可以颠倒,否则效果有可能不展示(相同的优先级) */
    106. /* 但是只有:link和:visit两者不需要固定顺序 */
    107. /* :link和a的样式可能冲突,冲突以代码后者为准 */
    108. .wrapper .website-hots > a:link {
    109. display: block;
    110. font-size: 1.6rem;
    111. text-decoration: none;
    112. color: #333;
    113. }
    114. .wrapper .website-hots > a:visited {
    115. color: #999;
    116. }
    117. .wrapper .website-hots > a:hover {
    118. color: red;
    119. }
    120. .wrapper .website-hots > a:active {
    121. color: coral;
    122. }

    效果图:
    四大门户热点新闻

Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:这些都是最基础的知识点, 可能以后的班级不再教学了,你们是赚到了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post