如何消除这个html/css页面中的水平滚动条创建引导?[duplicate]

idfiyjo8  于 2022-12-05  发布在  其他
关注(0)|答案(3)|浏览(139)

此问题在此处已有答案

How to remove this horizontal scrollbar in Bootstrap 3(8个答案)
How to make bootstrap 3 fluid layout without horizontal scrollbar(21个答案)
五年前就关门了。
我的问题是,当我在笔记本电脑上查看此页面时,页面底部出现了一个水平滚动条。我尝试过手动操作,但无法使其消失。还有一个问题是,当我在笔记本电脑上查看此页面时,它似乎太小,但当我在chrome中检查时,它似乎还不错。

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<style type="text/css">
  header {
    background-color: #EE6E73;
    width: 100%;
  }

  header h1 {
    margin: 0;
    font-size: 45px;
  }

  body {
    background-color: white;
    min-height: 100%;
  }

  footer {
    background-color: #EF9A9A;
    position: fixed;
    width: 100%;
    bottom: 0;
  }

  footer h2 {
    margin: 0;
  }

  header h1 {
    text-align: center;
  }

</style>
<title>My Resume</title>
</head>

<body>
<div class="row">
  <div class="col-sm-12 col-md-12 col-lg-12">
    <header>
      <h1>My Resume</h1></header>
  </div>
  <div class="col-sm-12 col-md-8 col-lg-8">
    <p style="font-size: 1.5625em">My name is John Doe. I have completed my abc from xyz and pursuing def from pqr. I am interested in making applications for the web and mobile, especially android os.</p>
  </div>

  <div class="col-sm-12 col-md-4 col-lg-4">
    <p style="font-size: 1.5625em">My hobbies are:
      <ol style="font-size: 1.5625em">
        <li>Playing basketball</li>
        <li>reading</li>
        <li>traveling</li>
      </ol>
  </div>
  <div class="col-sm-12 col-md-12 col-lg-12">
    <footer>
      <h2 align="center">Contact Me</h2>
      <br>
      <p align="center">John Doe</p>
      <p align="center">City</p>
    </footer>
  </div>
</body>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" 
integrity="sha384-
BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" 
crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" 
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-
theme.min.css" integrity="sha384-
rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" 
crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script 
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" 
integrity="sha384-
Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" 
crossorigin="anonymous"></script>

</html>

下面是一个jsfiddle链接:https://jsfiddle.net/zvdm6de4/1/

gkl3eglg

gkl3eglg1#

试试这个代码
在行换行时添加container-fluid div

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html>

  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <style type="text/css">
      header {
        background-color: #EE6E73;
        width: 100%;
      }
      
      header h1 {
        margin: 0;
        font-size: 45px;
      }
      
      body {
        background-color: white;
        min-height: 100%;
      }
      
      footer {
        background-color: #EF9A9A;
        position: fixed;
        width: 100%;
        bottom: 0;
      }
      
      footer h2 {
        margin: 0;
      }
      
      header h1 {
        text-align: center;
      }

    </style>
    <title>My Resume</title>
  </head>

  <body>
  <div class="container-fluid">
  
 
    <div class="row">
      <div class="col-sm-12 col-md-12 col-lg-12">
        <header>
          <h1>My Resume</h1></header>
      </div>
      <div class="col-sm-12 col-md-8 col-lg-8">
        <p style="font-size: 1.5625em">My name is John Doe. I have completed my abc from xyz and pursuing def from pqr. I am interested in making applications for the web and mobile, especially android os.</p>
      </div>


      <div class="col-sm-12 col-md-4 col-lg-4">
        <p style="font-size: 1.5625em">My hobbies are:
          <ol style="font-size: 1.5625em">
            <li>Playing basketball</li>
            <li>reading</li>
            <li>traveling</li>
          </ol>
      </div>
      <div class="col-sm-12 col-md-12 col-lg-12">
        <footer>
          <h2 align="center">Contact Me</h2>
          <br>
          <p align="center">John Doe</p>
          <p align="center">City</p>
        </footer>
      </div>
       </div>
  </body>
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

  <!-- Latest compiled and minified JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</html>
rur96b6h

rur96b6h2#

在body之后添加一个带有container-fluid类div,并将所有代码保留在此div之间。

qnyhuwrf

qnyhuwrf3#

将正文CSS更改为

body {
    background-color: white;
    min-height: 100%;
    overflow-x: hidden;
}

您可以根据需要在CSS文件中使用overflow-x:hiddenoverflow-x:scroll(用于水平滚动条)
通常,overflow-x用于水平滚动条,overflow-y用于垂直滚动条

相关问题