[英]How do I center my logo image and search field like the Google page? (Bootstrap)
I'm having a hard time styling this. 我在设计此样式时很难。 I just want my logo and search bar to be centered, with a bit more space above and below to fill the page.
我只希望徽标和搜索栏居中,在上方和下方留出更多空间来填充页面。 (This is at NE1UP dot com)
(这是在NE1UP点com上)
It's just a Google-esque page, that's all I want it to be, but I'm having a hard time getting this logo and search bar to align and display right, essentially like the Google page. 这只是一个Google风格的页面,这就是我想要的,但是我很难让这个徽标和搜索栏对齐并正确显示,就像Google页面一样。 I'm not sure if that's even the best option visually, but it's all I can visualize right now and just want to figure out what I'm doing wrong.
我不确定这在视觉上是否是最好的选择,但这就是我现在可以想象的,只是想弄清楚我在做什么错。
Thanks for ANY help! 谢谢你的帮助!
This is the code from index.htm 这是来自index.htm的代码
<div class="row">
<div class="span12">
<img src="soos.png" width="208px" height="72px">
<div class="span2">
</div>
<div class="span8">
<form action="search.php" method="get">
<input id="name" style="width:90%;height:50px;margin-top:0px" type="text" name="q" class="input-xxlarge" id="q" placeholder="Enter Search Term Here"/>
SEARCH 搜索
And the code from main.css: 以及来自main.css的代码:
.span8 input {display: block; margin-left: auto; margin-right: auto;}
.span8 button {margin-left:4.8%} .span8按钮{margin-left:4.8%}
I don't know the bootstrap way but if you stick to traditional CSS, you can use position: absolute;
我不知道引导方式,但是如果您坚持使用传统CSS,则可以使用
position: absolute;
for this 为了这
.logo {
position: absolute;
left: 50%;
top: 50%;
width: 300px;
height: 100px;
margin-top: -50px; /* Half of total height */
margin-left: -150px; /* Half of total width */
}
If the element you want to center has display:inline applied to it, then you can use margin centering. 如果要居中的元素已应用display:inline,则可以使用边距居中。 Apply this this to the element you want to center:
将此应用到要居中的元素:
div.centerthis {
display:inline;
margin-left:auto;
margin-right:auto;
}
This assumes the that parent of this element has enough space for the child to center. 假定该元素的父级有足够的空间让子级居中。 The parent would need to be set to display:block;
父项需要设置为display:block; and/or have width:100% or something similar to ensure there is space for centering the child.
和/或宽度:100%或类似值,以确保有足够的空间将孩子居中。
It would be helpful to have something on JSfiddle or Codepen to work with. 在JSfiddle或Codepen上使用某些东西会很有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.