让文本显示在导航栏下(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
满意答案
这是适用于我的解决方案。
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.
相关问答
更多工厂女孩嵌套协会(Factory Girl Nested Associations)
如何在工厂女孩中创建has_and_belongs_to_many关联(How to create has_and_belongs_to_many associations in Factory girl)
工厂女孩与同一父母有多个联系(Factory Girl with multiple associations with the same parent)
Factory_girl使用#create_list,在所有创建的对象之间共享相同的关联(Factory_girl using #create_list, share the same associations between all created objects)
使用带参数的范围和与ActiveRecord(Ruby)的has_and_belongs_to_many关联(using scopes with parameters and has_and_belongs_to_many associations with ActiveRecord (Ruby))
多个工厂女孩协会问题(Multiple Factory Girl associations issue)
如何使用has_and_belongs_to_many关联获取FactoryGirl模型属性?(How to get FactoryGirl model attributes with has_and_belongs_to_many association?)
工厂女孩 - 有很多协会(Factory Girl - has many associations)
Rspec,Factory Girl使用has_many构建(Rspec, Factory Girl build with has_many)
无法让'has_and_belongs_to_many'工作(Can't get 'has_and_belongs_to_many' to work)
相关文章
更多网络挖掘技术——text mining
左则导航鼠标滑过时显示详情的实现
java.text.DecimalFormat 的问题
企业级搜索引擎Solr 第二章 Schema和文本分析(Schema and Text Analysis)[2]
Solr官方文档系列——Text Analysis
Django and full-text search
jquery 怎么得到link中text的属性
Full-Text Search in ASP.NET using Lucene.NET
用‘button’跟‘text’组合代替‘file’,选择文件后点‘submit’,‘file’的值被清空
最新问答
更多获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
如何通过引用返回对象?(How is returning an object by reference possible?)
矩阵如何存储在内存中?(How are matrices stored in memory?)
每个请求的Java新会话?(Java New Session For Each Request?)
css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
xcode语法颜色编码解释?(xcode syntax color coding explained?)
在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
Copyright ©2023 peixunduo.com All Rights Reserved.粤ICP备14003112号
本站部分内容来源于互联网,仅供学习和参考使用,请莫用于商业用途。如有侵犯你的版权,请联系我们(neng862121861#163.com),本站将尽快处理。谢谢合作!