[英]2 class of col-md-6 can't make element stack horizontally
I'm trying to make footer that consist of 2 anchor text and I want to make both of those anchor text placed side by side (not vertically). 我正在尝试使页脚包含2个锚文本,并且我想使两个锚文本并排放置(而不是垂直放置)。
Here's my HTML: 这是我的HTML:
<footer>
<div class="container">
<div class="row">
<div class="col-md-6">
<a href='#'>BRAND</a>
</div>
<div class="col-md-2">
<a href='#'>Social 1</a>
</div>
<div class="col-md-2">
<a href='#'>Social 2</a>
</div>
<div class="col-md-2">
<a href='#'>Social 3</a>
</div>
</div>
</div>
</footer>
And here's the CSS: 这是CSS:
footer {
bottom: 0;
width: 100%;
height: 50px;
text-align: center;
background: -webkit-linear-gradient(top, rgba(125,126,125,1) 0%,rgba(14,14,14,1) 10%);
}
Here's my Jsfiddle Can you help me figure it out what's wrong? 这是我的Jsfiddle 。您能帮我弄清楚出什么问题吗? Thank you
谢谢
I don't see any issues with it after fixing the bootstrap link. 修复引导链接后,我看不到任何问题。 Are you sure you have viewed the outcome in the browser window wide enough - so you are not rendering a smaller than medium (md) view?
您确定您已经在浏览器窗口中查看了足够宽的结果-因此您没有呈现小于中(md)视图的结果吗?
You have the right idea to add col-md-2
to each link. 您有正确的想法将
col-md-2
添加到每个链接。 Make sure you have the bootstrap CSS loaded on the page. 确保在页面上加载了引导CSS。
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
Make sure you're viewing the page on md
(or larger) screen size. 确保您正在以
md
(或更大)屏幕尺寸查看页面。 Alternatively, use col-sm-*
or col-xs-*
styles. 或者,使用
col-sm-*
或col-xs-*
样式。 Following sizes are used: 使用以下尺寸:
xs: Extra small devices (phones, less than 768px)
md: Small devices (tablets, 768px and up)
sm: Medium devices (desktops, 992px and up)
lg: Large devices (large desktops, 1200px and up)
An improvement would be to use col-md-offset-2 col-md-2
on the first link, instead of col-md-6
. 一种改进是在第一个链接上使用
col-md-offset-2 col-md-2
,而不是col-md-6
。
footer { bottom: 0; width: 100%; height: 50px; text-align: center; background: -webkit-linear-gradient(top, rgba(125, 126, 125, 1) 0%, rgba(14, 14, 14, 1) 10%); }
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> <!-- Shows this working with `col-xs-*` (to make it viewable on small code snippet screen). --> <footer> <div class="container"> <div class="row"> <div class="col-xs-offset-2 col-xs-2"> <a href='#'>BRAND</a> </div> <div class="col-xs-2"> <a href='#'>Social 1</a> </div> <div class="col-xs-2"> <a href='#'>Social 2</a> </div> <div class="col-xs-2"> <a href='#'>Social 3</a> </div> </div> </div> </footer>
https://jsfiddle.net/32gund40/6/ https://jsfiddle.net/32gund40/6/
Updated fiddle you weren't including the bootstrap stylesheet 更新了小提琴,您没有包含引导样式表
Adjust the col-md-6
classes to col-xs-6
if you need it the same col width on mobile 如果您需要在移动设备上使用相同的col宽度,请将
col-md-6
类调整为col-xs-6
use 采用
<div class="clear:both"></div>
just before the closing tag of row div and distribute the tags like I did. 就在div 行的结束标签之前,然后像我一样分发标签。
<footer>
<div class="container">
<div class="row">
<div class="col-md-6">
<a href='#'>BRAND</a>
</div>
*<div class="col-md-6">*
<div class="col-md-2">
<a href='#'>Social 1</a>
</div>
<div class="col-md-2">
<a href='#'>Social 2</a>
</div>
<div class="col-md-2">
<a href='#'>Social 3</a>
</div>
*</div>*
**<div class="clear:both"></div>**
</div>
</div>
</footer>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.