css – Bootstrap container-fluid不是屏幕的整个宽度

前端之家收集整理的这篇文章主要介绍了css – Bootstrap container-fluid不是屏幕的整个宽度前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在做一个网站,我首先从移动样式表开始.
但容器流体的宽度与窗口的宽度不同.

我试图解决这个问题的方法是:

  1. .container-fluid{
  2. width: 105%
  3. }

现在的问题是,当我使窗口变小时,它仍然不够,但是当我使窗口变大一点时,它太多了,当我这样做时,底部会出现一个滚动条.

100%不起作用,因为我已经说过它不是窗口的全宽.

这是HTML文件中的整个正文:

  1. <body>
  2. <!-- Introduction -->
  3.  
  4. <div id="introduction" class="container-fluid">
  5. <div class="row">
  6. <header>
  7. <h1> Mosescu Bogdan Gabriel </h1>
  8. <img id="profilepic" src="profilepic.png" />
  9. <h2> Web Designer | Motion Graphics Artist </h2>
  10. </header>
  11. </div>
  12. </div>
  13. <!-- //Introduction// -->
  14.  
  15. <div id="about" class="container-fluid">
  16. <div class="row">
  17. <h1 id="about-title"> Who I am </h1>
  18. </div>
  19. </div>
  20. </body>

这是CSS文件

  1. /*Introduction CSS */
  2. #introduction{
  3. background-color: #542437;
  4. color: white;
  5. margin-top: -21px;
  6. }
  7. #introduction header{
  8. text-align: center;
  9. }
  10. #introduction header h1{
  11. font-family: montserrat;
  12. font-weight: bold;
  13. }
  14. #introduction header h2{
  15. font-family: montserrat;
  16. font-weight: normal;
  17. font-size: 1em;
  18. }
  19. #profilepic{
  20. border-radius: 100%;
  21. width: 150px;
  22. height: 150px;
  23. }
  24. /* //Introduction CSS// */
  25.  
  26.  
  27. /* About CSS */
  28. #about{
  29. background-color: #f2f2f2;
  30. color: #1a1a1a;
  31. text-align: center;
  32. margin-top: -24px;
  33. }
  34. #about-title{
  35. font-family: montserrat;
  36. font-weight: bold;
  37. font-size: 2.25em;
  38. border-bottom: solid 1px black;
  39. }

解决方法

Bootstrap容器是填充的.
  1. .container-fluid {
  2. padding-right:15px;
  3. padding-left:15px;
  4. margin-right:auto;
  5. margin-left:auto
  6. }

您需要删除填充.

  1. .container-fluid {
  2. padding-right:0;
  3. padding-left:0;
  4. margin-right:auto;
  5. margin-left:auto
  6. }

编辑:这是一个简单的例子.如果您将其复制并粘贴到新的.html文档中,您将看到容器上没有填充.如果你然后删除容器 – 流体覆盖,你会看到填充.

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <Meta charset="utf-8">
  5. <Meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <title></title>
  7. <Meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
  8. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
  9.  
  10. <!-- put your override styles here - AFTER you include Bootstrap -->
  11. <link href="style-mobile.css" rel="stylesheet">
  12.  
  13. </head>
  14. <style>
  15. /* override Bootstrap's container */
  16. .container-fluid {
  17. padding-right:0;
  18. padding-left:0;
  19. margin-right:auto;
  20. margin-left:auto
  21. }
  22. </style>
  23. <body>
  24.  
  25. <div class="container-fluid">
  26. This text hits the left side of the viewport.
  27. </div>
  28.  
  29. </body>
  30. </html>

编辑HTML示例以包含新的CSS链接

猜你在找的CSS相关文章