引导和居中网页

时间:2016-09-27 03:35:24

标签: html css twitter-bootstrap dreamweaver

我正在尝试使用Bootstrap在Dreamweaver CC中创建一个简单的网页。我无法弄清楚如何使显示的网页在浏览器中居中。该页面保持左对齐。这是我试图使用的代码:

HTML5& CSS



<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Pixinsight Basics</title>
    <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet" type="text/css">
  </head>

  <body>
  <div class="container-fluid">
  <section class="row">

    <header id="banner">
    <h1>Pixinsight Basics</h1>
    </header>

    <div class="col-sm-6">
<h3>Heading 3</h3>
    <p>Hello my fellow astronomers. I have chosen to use Pixinsight
 as my primary processing software. Like you (probably) I have sifted
 around the internet looking for information/tutorials on how to use
 Pixinsight. While this is by no means a comprehensive data set on
 how to use Pixinsight, it should at least get you up and running. 
I have divided this information into 3 distinct processing areas of 
interest:</p>
<ul>
  <li>
    <!--[if !supportLists]--><!--[endif]-->
    Calibration</li>
  <li>
    <!--[if !supportLists]--><!--[endif]-->
    Linear</li>
  <li>
    Non–Linear</li>
</ul>
<p>Just click on one of the buttons below and it will
 take you to your area of interest.</p>
</div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="js/jquery-1.11.2.min.js"></script>


    <script src="js/bootstrap.js"></script>
    </section>
    </div> <!--container-fluid-->

    </body>
</html>
&#13;
class Log < ActiveRecord::Base
  has_and_belongs_to_many :tags
  has_one :asset
  has_one :user
  belongs_to :user

  after_create :save_user

  def save_user
    self.user_id = :current_user
    self.save()
  end
end
describe Log do
    context "When saving a user is should save to the database."

    it "should call insert fields with appropriate arguments" do
    expect(subject).to receive(:asset).with("TestData")
    expect(subject).to receive(:user).with("DummyName")
    expect(subject).to save_user 
    subject.foo
end
end 
&#13;
&#13;
&#13;

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

要解决此问题,请移除正文宽度,并为容器流体添加宽度,结果为 css:

#banner {
  background-image: url(../images/2000%20x%20150_Bubble_Final_Crop.jpg);
  height: 150px;
}
body {
  margin:0;
  padding:0;
}
h1 {
  color: #FFFFFF;
  padding-top: 25px;
  font-family: Cambria, "Hoefler Text", "Liberation Serif", 
    Times, "Times New Roman", serif;
  font-size: 58pt;
  text-shadow: 2px 2px 24px #D7DC23;
  text-align: center;
}
.container-fluid {
  margin: 0 auto;
  width: 1200px;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Pixinsight Basics</title>
    <!-- Bootstrap -->
    <link href="css/bootstrap.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet" type="text/css">
  </head>

  <body>
  <div class="container-fluid">
  <section class="row">

    <header id="banner">
    <h1>Pixinsight Basics</h1>
    </header>

    <div class="col-sm-6">
<h3>Heading 3</h3>
    <p>Hello my fellow astronomers. I have chosen to use Pixinsight
 as my primary processing software. Like you (probably) I have sifted
 around the internet looking for information/tutorials on how to use
 Pixinsight. While this is by no means a comprehensive data set on
 how to use Pixinsight, it should at least get you up and running. 
I have divided this information into 3 distinct processing areas of 
interest:</p>
<ul>
  <li>
    <!--[if !supportLists]--><!--[endif]-->
    Calibration</li>
  <li>
    <!--[if !supportLists]--><!--[endif]-->
    Linear</li>
  <li>
    Non–Linear</li>
</ul>
<p>Just click on one of the buttons below and it will
 take you to your area of interest.</p>
</div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="js/jquery-1.11.2.min.js"></script>


    <script src="js/bootstrap.js"></script>
    </section>
    </div> <!--container-fluid-->

    </body>
</html>

答案 1 :(得分:0)

您必须删除正文规则

body {
    width: 1200px;
}

以及容器流体规则

.container-fluid {
    margin: 0 auto;
}
来自你的CSS

。将课程col-sm-6替换为col-sm-12,并为此div添加课程text-center。 如果您想要左右两侧的排水沟,请使用课程container而不是container-fluid。选择是你的。但我建议您使用container课程,因为它适合您的需要。

最后一眼:

<!DOCTYPE html>
<html>
<head>
    <title>Regent</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="css/bootstrap.css" rel="stylesheet" />
    <style>
#banner {
    background-image: url(../images/2000%20x%20150_Bubble_Final_Crop.jpg);
    height: 150px;
}

h1 {
    color: #FFFFFF;
    padding-top: 25px;
    font-family: Cambria, "Hoefler Text", "Liberation Serif", 
    Times, "Times New Roman", serif;
    font-size: 58pt;
    text-shadow: 2px 2px 24px #D7DC23;
    text-align: center;
}

    </style>
</head>
<body>

  <div class="container">
  <section class="row">

    <header id="banner">
    <h1>Pixinsight Basics</h1>
    </header>

    <div class="col-sm-12 text-center">
<h3>Heading 3</h3>
    <p>Hello my fellow astronomers. I have chosen to use Pixinsight
 as my primary processing software. Like you (probably) I have sifted
 around the internet looking for information/tutorials on how to use
 Pixinsight. While this is by no means a comprehensive data set on
 how to use Pixinsight, it should at least get you up and running. 
I have divided this information into 3 distinct processing areas of 
interest:</p>
<ul>
  <li>
    <!--[if !supportLists]--><!--[endif]-->
    Calibration</li>
  <li>
    <!--[if !supportLists]--><!--[endif]-->
    Linear</li>
  <li>
    Non–Linear</li>
</ul>
<p>Just click on one of the buttons below and it will
 take you to your area of interest.</p>
</div>


    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
    <script src="js/jquery-1.11.2.min.js"></script>


    <script src="js/bootstrap.js"></script>
    </section>
    </div> <!--container-fluid-->

</body>
</html>