首页 \ 问答 \ 让文本显示在导航栏下(Getting text to appear under navbar)

让文本显示在导航栏下(Getting text to appear under navbar)

我想让我的文字出现在屏幕中间。 我已经完成了这个工作,但是我认为我已经在编码方面做得不好,我想看看是否有更好的方法可以不做。

所以我这样做的方式是

.homeMess {

    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -109px;
    margin-left: -725px;
}

但使用margin-left: -725px; 我并不了解,所以试图寻找另一种方式。

我的html:

    <div class="parallax">

 <div class="navbar navbar-default navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
                <div class="logo"><img src="Images/logo1.png"></div>
        </div>
          <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
              <li><a href="#">a</a></li>
              <li><a href="#">b</a></li>
              <li><a href="#">c</a></li>
              <li><a href="#">d</a></li>
            </ul>
          </div><!--/.nav-collapse -->
      </div>
    </div>
    <div class="container">
            <div class="homeMess ">
            <h1> a| v
        </div>
    </div>
        </div>

CSS:

body {
    font-family: 'Open Sans', sans-serif, Arial;
    font-size: 16px;
    color: #6D6D6D;
    background-color: #F5F5F5;
    font-weight: 300;
}
h1,h2,h3,h4,h5,h6 {
    font-family: 'Montserrat', sans-serif, Arial;

    padding-bottom: 5px;
    color: #373432;
    line-height: 1em;
    font-weight: normal;
}
a {
    text-decoration: none;
    outline: none;
}


.parallax {
    background-image: url("../Images/back1.jpg");
    min-height: 1000px;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    width: 100%;
}

.parallax1 {
    min-height: 1000px;
}


.container {
    margin: 0;
    width: auto;
}   


.navbar-nav {
    float: right;
    margin-top: -15px;
}


.navbar-nav>li>a {
    line-height: 6px;
}


.navbar {
  padding-top: 46px;
  padding-right: 60px;
  font-size: 13px;
  text-transform: uppercase;
}

.navbar-default {
    background-color: transparent;
    border-top: 0px solid rgba(0, 0, 0, 0.5);
    border-bottom: 0px solid rgba(0, 0, 0, 0.5);
    border-left: 0px solid rgba(0, 0, 0, 0.5);
    border-right: 0px solid rgba(0, 0, 0, 0.5);
  -webkit-transition: background-color 200ms linear;
  -moz-transition: background-color 200ms linear;
  -o-transition: background-color 200ms linear;
  -ms-transition: background-color 200ms linear;
  transition: background-color 200ms linear;
  height: 87px;
}

.navbar-default .navbar-nav>li>a {
    color: #ffffff;
}

.navbar-default .navbar-nav > li > a:hover, 
.navbar-default .navbar-nav > li > a:focus {
      background-color: #F8BD23;
      text-decoration: none;
       color: #ffffff;
    -webkit-transition: background-color 200ms linear;
    -moz-transition: background-color 200ms linear;
    -o-transition: background-color 200ms linear;
    -ms-transition: background-color 200ms linear;
    transition: background-color 200ms linear;
    }

    .navbar-nav > li{
  padding-left:30px;

}

.logo {
    margin-left: 40px;
    margin-top: -17px;

}

.homeMess {

    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -109px;
    margin-left: -725px;
}

.homeMess h1 {
    font-size: 100px;
    text-transform: uppercase;
    font-weight: 900;
    font-size: 60px;
    letter-spacing: -5px;
    line-height: 50px;
    color: white;

}

所以我只是想让homeMess教室的课程处于屏幕中间,但我的做法并不好。 另外我正在使用bootstrap v3。


I want to get my text to appear in the middle of the screen. I have done this but I think I have done this in a bad way of coding and I want to see if there is a better way of doing it without doing.

So the way I did it was

.homeMess {

    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -109px;
    margin-left: -725px;
}

but using margin-left: -725px; is not amazing I know so trying to find another way.

My html:

    <div class="parallax">

 <div class="navbar navbar-default navbar-fixed-top" role="navigation">
      <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
              <span class="sr-only">Toggle navigation</span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
              <span class="icon-bar"></span>
            </button>
                <div class="logo"><img src="Images/logo1.png"></div>
        </div>
          <div id="navbar" class="navbar-collapse collapse">
            <ul class="nav navbar-nav">
              <li><a href="#">a</a></li>
              <li><a href="#">b</a></li>
              <li><a href="#">c</a></li>
              <li><a href="#">d</a></li>
            </ul>
          </div><!--/.nav-collapse -->
      </div>
    </div>
    <div class="container">
            <div class="homeMess ">
            <h1> a| v
        </div>
    </div>
        </div>

CSS:

body {
    font-family: 'Open Sans', sans-serif, Arial;
    font-size: 16px;
    color: #6D6D6D;
    background-color: #F5F5F5;
    font-weight: 300;
}
h1,h2,h3,h4,h5,h6 {
    font-family: 'Montserrat', sans-serif, Arial;

    padding-bottom: 5px;
    color: #373432;
    line-height: 1em;
    font-weight: normal;
}
a {
    text-decoration: none;
    outline: none;
}


.parallax {
    background-image: url("../Images/back1.jpg");
    min-height: 1000px;
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    width: 100%;
}

.parallax1 {
    min-height: 1000px;
}


.container {
    margin: 0;
    width: auto;
}   


.navbar-nav {
    float: right;
    margin-top: -15px;
}


.navbar-nav>li>a {
    line-height: 6px;
}


.navbar {
  padding-top: 46px;
  padding-right: 60px;
  font-size: 13px;
  text-transform: uppercase;
}

.navbar-default {
    background-color: transparent;
    border-top: 0px solid rgba(0, 0, 0, 0.5);
    border-bottom: 0px solid rgba(0, 0, 0, 0.5);
    border-left: 0px solid rgba(0, 0, 0, 0.5);
    border-right: 0px solid rgba(0, 0, 0, 0.5);
  -webkit-transition: background-color 200ms linear;
  -moz-transition: background-color 200ms linear;
  -o-transition: background-color 200ms linear;
  -ms-transition: background-color 200ms linear;
  transition: background-color 200ms linear;
  height: 87px;
}

.navbar-default .navbar-nav>li>a {
    color: #ffffff;
}

.navbar-default .navbar-nav > li > a:hover, 
.navbar-default .navbar-nav > li > a:focus {
      background-color: #F8BD23;
      text-decoration: none;
       color: #ffffff;
    -webkit-transition: background-color 200ms linear;
    -moz-transition: background-color 200ms linear;
    -o-transition: background-color 200ms linear;
    -ms-transition: background-color 200ms linear;
    transition: background-color 200ms linear;
    }

    .navbar-nav > li{
  padding-left:30px;

}

.logo {
    margin-left: 40px;
    margin-top: -17px;

}

.homeMess {

    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -109px;
    margin-left: -725px;
}

.homeMess h1 {
    font-size: 100px;
    text-transform: uppercase;
    font-weight: 900;
    font-size: 60px;
    letter-spacing: -5px;
    line-height: 50px;
    color: white;

}

So I am just trying to get the homeMess class to be in the middle of the screen but the way I am doing it is not good. Also I am using bootstrap v3.


原文:https://stackoverflow.com/questions/45394524
更新时间:2022-08-10 16:08

最满意答案

这是适用于我的解决方案。

FactoryGirl.define do

  factory :company do
    #company attributes
  end

  factory :user do
   companies {[FactoryGirl.create(:company)]}
   #user attributes
  end

end

如果你需要特定的公司,你可以这样使用工厂

company = FactoryGirl.create(:company, #{company attributes})
user = FactoryGirl.create(:user, :companies => [company])

希望这将有助于某人。


Factorygirl has since been updated and now includes callbacks to solve this problem. Take a look at http://robots.thoughtbot.com/post/254496652/aint-no-calla-back-girl for more info.

相关问答

更多

相关文章

更多

最新问答

更多
  • 如何在Laravel 5.2中使用paginate与关系?(How to use paginate with relationships in Laravel 5.2?)
  • linux的常用命令干什么用的
  • 由于有四个新控制器,Auth刀片是否有任何变化?(Are there any changes in Auth blades due to four new controllers?)
  • 如何交换返回集中的行?(How to swap rows in a return set?)
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • 使用Boost.Spirit Qi和Lex时的空白队长(Whitespace skipper when using Boost.Spirit Qi and Lex)
  • Java中的不可变类(Immutable class in Java)
  • WordPress发布查询(WordPress post query)
  • 如何在关系数据库中存储与IPv6兼容的地址(How to store IPv6-compatible address in a relational database)
  • 是否可以检查对象值的条件并返回密钥?(Is it possible to check the condition of a value of an object and JUST return the key?)
  • GEP分段错误LLVM C ++ API(GEP segmentation fault LLVM C++ API)
  • 绑定属性设置器未被调用(Bound Property Setter not getting Called)
  • linux ubuntu14.04版没有那个文件或目录
  • 如何使用JSF EL表达式在param中迭代变量(How to iterate over variable in param using JSF EL expression)
  • 是否有可能在WPF中的一个单独的进程中隔离一些控件?(Is it possible to isolate some controls in a separate process in WPF?)
  • 使用Python 2.7的MSI安装的默认安装目录是什么?(What is the default installation directory with an MSI install of Python 2.7?)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • ckeditor config.protectedSource不适用于editor.insertHtml上的html元素属性(ckeditor config.protectedSource dont work for html element attributes on editor.insertHtml)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 将CouchDB与AJAX一起使用是否安全?(Is it safe to use CouchDB with AJAX?)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • 无法在新线程中从FREContext调用getActivity()?(Can't call getActivity() from FREContext in a new thread?)
  • 在Alpine上升级到postgres96(/ usr / bin / pg_dump:没有这样的文件或目录)(Upgrade to postgres96 on Alpine (/usr/bin/pg_dump: No such file or directory))
  • 如何按部门显示报告(How to display a report by Department wise)
  • Facebook墙贴在需要访问令牌密钥后无法正常工作(Facebook wall post not working after access token key required)
  • Javascript - 如何在不擦除输入的情况下更改标签的innerText(Javascript - how to change innerText of label while not wiping out the input)
  • WooCommerce / WordPress - 不显示具有特定标题的产品(WooCommerce/WordPress - Products with specific titles are not displayed)