不在“引导”列中居中文本 [英] Not centered text in Bootstrap column

查看:112
本文介绍了不在“引导”列中居中文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Bootstrap中构建了一个1-10-1列的标题结构。现在,我想将此置于10列中心。但是正如你可以通过页面中间的虚线看到的不是在正中的中心。为什么不?

I constructed a 1-10-1-column header construction in Bootstrap. Now I want to center this ! in the 10-column. But as you can see by the dotted lines in the middle of the page ! is not centered in the exact middle. Why not? And how can I get it there?

标题的高度取决于 font-size 文本。如何通过命令手动设置标题的高度?

And the height of the header depends on the font-size of the text in it. How can I set the height of the header manually by a command?

HTML:

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>JFP</title>
    <link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css">
        <link rel="stylesheet" href="/static/main.css" >
    <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.4.0/css/font-awesome.min.css">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="/static/app.js"></script>
</head>

<body>

<div id="body-wrapper">
<div class="menu">
        <div class="icon-close">
            <img src="http://s3.amazonaws.com/codecademy-content/courses/ltp2/img/uber/close.png">
        </div>

        <ul>
            <li><a href="#">About</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
</div>

<div class="container-fluid">
    <div class="header">
        <div class="row">
            <div class="col-md-1 text-center">
                <div class="icon-menu">
                    <i class="fa fa-bars"></i>
                </div>
            </div>
            <div class="col-md-10 text-center">
                <li><a>!</a></li>
            </div>
            <div class="col-md-1 text-center">
            </div>
            </ul>
        </div>
    </div>
</div>


<div class="jumbo"></div>

<div class="footer">
    <div class="container">
        <p>&copy; Lorem ipsum.</p>
    </div>
</div>
</div>

</body>

</html>

CSS:

html {}

body{
    left: 0;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
}

body:after {
    content: "";
    position: absolute;
    z-index: -1;
    top: 0px;
    bottom: 0px;
    left: 50%;
    border-left: 1px dotted #333333;
}

.menu {
    left: -185px;
    height: 200%;
    position: fixed;
    width: 185px;
}

.menu ul {
    border-top: 1px solid rgb(51,51,51);
    list-style: none;
    margin: 0;
    padding: 0;
}

.menu li {
    border-bottom: 1px solid rgb(51,51,51);
    font-family: 'Open Sans', sans-serif;
    line-height: 45px;
    padding-bottom: 3px;
    padding-left: 20px;
    padding-top: 3px;
}

.menu a {
    color: rgb(51,51,51);
    font-size: 15px;
    text-decoration: none;
    text-transform: uppercase;
}

.icon-close {
    cursor: pointer;
    padding-left: 10px;
    padding-top: 10px;
}

.header {
}

.header i {
    font-size: 30px;
    margin-top: 15px;
}

.header a{
    color: rgb(250,250,250);
    font-size: 40px;
    text-align: center;
}

.header .col-md-10 {
    background-color: rgb(51,51,51);
    width: 85%;
    margin-left:auto;
    margin-right:auto;
    border-bottom-left-radius: 40px;
    border-bottom-right-radius: 40px;
}

.footer {
    background-color: rgb(51,51,51);
    color: rgb(51,51,51);
    padding: 30px 0;
    margin-top: 1000px;
}

.footer p {
    color: rgb(250,250,250);
    font-family: 'Raleway', sans-serif;
    text-transform: normal;
    font-size: 11px;
}

@media (max-width: 500px) {
    .main h1 {
        font-size: 50px;
        padding: 0 40px;
    }
    .supporting .col {
        width: 100%;
    }
}

JS:

$(document).ready(function() {
    $(".icon-menu").click(function() {
    $(".menu").animate({
    left: "0px"
    }, 600);
    $(".icon-menu").toggle(1600);

    $("body").animate({
    left: "185px"
    }, 600);
    });
});

$(document).ready(function() {
$('.icon-close').click(function() {
    $('.menu').animate({
    left: "-185px"
    }, 600);
    $(".icon-menu").toggle(600);

    $('body').animate({
    left: "0px"
    }, 600);
    });
});

Codepen

推荐答案

尝试:

<div class="row col-md-12">
...
     <div class="col-md-10 text-center">
          <li><a>!</a></li>
     </div>
...
</div>

如果要更改页眉的高度,请尝试为div设置高度,例如:

If you want change height of header try to set height for div, for example:

<div class="col-md-10 text-center" style="height:100px;">
     <li><a>!</a></li>
</div>

当然对于好的风格,在css中创建一个特定的风格,值为height,然后添加到class你的div。

Of course for good style, create a specific style at css with value of height and add to class of your div.

这篇关于不在“引导”列中居中文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆