对齐按钮居中小屏幕引导程序

时间:2017-10-05 21:31:21

标签: html css twitter-bootstrap

当屏幕尺寸变小时,我试图将我的按钮与移动屏幕的中心对齐,尝试将文本对齐设置为中心,但这似乎无法正常工作。

它必须是拉左/文本右引导类我试图覆盖的东西,只是不太确定我错过了什么。

CSS:

@media screen and (max-width: 998px) {

    @font-face{
        font-family: 'Gotham';
        src: url("assets/fonts/Gotham-Bold.otf");
        src: url("assets/fonts/Gotham-Light.otf");
    }

    @font-face {
    font-family: "Gotham-Bold";
    src: url("assets/fonts/Gotham-Bold.otf");
    font-weight: Bold;
    }

    @font-face {
    font-family: "Gotham-Light";
    src: url("assets/fonts/Gotham-Light.otf");
    font-weight: Light;
    }

    .col-md-4.pull-left.text-right{
        position: relative;
        text-align: center;
    }
.
.
.

HTML:

<div class="container-fluid">
    <div class="row">
            <div class="col-sm-8 pull-right text-left" >
                <div class="IMGpadding"></div><br>
                <img style="float:left" class="img-responsive" src = "assets/images/white-leaf-bg.jpg" id="frame"/>
            </div>
            <div class="col-md-4 pull-left text-right" >
                <div class="h1padding"></div>
                <a style="float:right" class = "h1" href="" id="introID"><b>INTRO</b></a>

                <div class="h1padding"></div>
                <a style="float:right" class = "h1" href="" id="OnSuerfaceID"><b>ON THE</b> <span class="light">SURFACE</span></a>

                <div class="h1padding"></div>
                <a style="float:right"  href="" id="FromOilID"><b>FROM</b> <span class="light">ORE TO OIL</span></a>

                <div class="h1padding"></div>
                <a style="float:right"  href="" id="EnvImpactID"><b>ENVIRONMENTAL</b> <span class="light">CARE</span></a>

                <div class="h1padding"></div>
                <a style="float:right" class = "h1" href="" id="MoreThanGasID"><b>MUCH MORE THAN</b> <span class="light">GASOLINE</span></a>

                <div class="h1padding"></div>
                <a style="float:right" class = "h1" href="" id="OneMoreID"><b>ONE MORE</b> <span class="light">THING</span></a>

            </div>
    </div>
</div>

Current look

在此先感谢,我仍然是训练营的小伙伴。

2 个答案:

答案 0 :(得分:1)

这取决于您的其他页面以及。根据您在此处添加的要求和代码,我在codepen中添加了一个工作副本。试试这个: enter image description here

@media screen and (max-width: 998px) {

    @font-face{
        font-family: 'Gotham';
        src: url("assets/fonts/Gotham-Bold.otf");
        src: url("assets/fonts/Gotham-Light.otf");
    }

    @font-face {
    font-family: "Gotham-Bold";
    src: url("assets/fonts/Gotham-Bold.otf");
    font-weight: Bold;
    }

    @font-face {
    font-family: "Gotham-Light";
    src: url("assets/fonts/Gotham-Light.otf");
    font-weight: Light;
    }

    .col-sm-4.pull-left.text-right{
        position: relative;
        text-align: right;
      width:50%;
      text-align:right;
    }
  .h1padding {
    margin-bottom:100px;
  }
}
 
<div class="container-fluid">
    <div class="row">
            <div class="col-sm-8 pull-right text-left" >
                <div class="IMGpadding"></div><br>
                <img style="float:left" class="img-responsive" src = "assets/images/white-leaf-bg.jpg" id="frame"/>
            </div>
            <div class="col-sm-4 pull-left text-right" >
                <div class="h1padding"></div>
                <a class = "h1" href="" id="introID"><b>INTRO</b></a>

                <div class="h1padding"></div>
                <a class = "h1" href="" id="OnSuerfaceID"><b>ON THE</b> <span class="light">SURFACE</span></a>

                <div class="h1padding"></div>
                <a  href="" id="FromOilID"><b>FROM</b> <span class="light">ORE TO OIL</span></a>

                <div class="h1padding"></div>
                <a  href="" id="EnvImpactID"><b>ENVIRONMENTAL</b> <span class="light">CARE</span></a>

                <div class="h1padding"></div>
                <a class = "h1" href="" id="MoreThanGasID"><b>MUCH MORE THAN</b> <span class="light">GASOLINE</span></a>

                <div class="h1padding"></div>
                <a class = "h1" href="" id="OneMoreID"><b>ONE MORE</b> <span class="light">THING</span></a>

            </div>
    </div>
</div>

codepen link

答案 1 :(得分:0)

由于您使用的是bootstrap,因此可以使用.visible-sm.visible-md.visible-lg类。有关详细信息:https://getbootstrap.com/docs/3.3/css/#responsive-utilities