2016-09-25 91 views
0

我是新手引导。 我必须使用bootstrap在两个div之间添加圆圈。 我已经添加了html,但它不适合我。 所以,请帮我找到解决方案。 感谢添加圈子并使用Bootstrap创建像这样的UI?

enter image description here

<div class="row"> 
    <div class="col-md-12" style="background-color:pink;height:74px;"></div> 
</div> 

<div class="blue-cirle-div"><img src="./images/donald.jpg" class="img-circle" width="75" height="75" /></div> 
<div class="row"> 
    <div class="col-md-12" style="background-color:yellow;height:74px;"></div> 
</div> 
+0

如果有任何发布的答案解决了您的问题,请接受它,如果没有,请告诉我们,我们可以为您找到一个 – LGSon

回答

1

保持您的标记原样,这里是一个建议,使用position: relative/z-index: 1将其移到顶部,并给它一个width/margin使其居中auto和将上面/下面的元素靠拢-20px

.blue-cirle-div { 
 
    position: relative; 
 
    width: 74px; 
 
    height: 74px; 
 
    margin: -20px auto; 
 
    z-index: 1; 
 
    border-radius: 50%; 
 
    border: 1px solid blue; 
 
} 
 
.center-children { 
 
    padding-top: 40px; 
 
    text-align: center; 
 
} 
 
.photos { 
 
    margin-right: 40px; 
 
} 
 
.photos ~ .photos { 
 
    margin-right: 0px; 
 
    margin-left: 40px; 
 
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> 
 

 
<div class="row"> 
 
    <div class="col-md-12" style="background-color:pink;height:74px;"></div> 
 
</div> 
 

 
<div class="blue-cirle-div"> 
 
    <img src="http://placehold.it/72" class="img-circle" width="72" height="72" /> 
 
</div> 
 

 
<div class="row"> 
 
    <div class="col-md-12 center-children" style="background-color:yellow;height:74px;"> 
 

 
    <img src="http://placehold.it/120" class="photos" /> 
 
    <img src="http://placehold.it/120" class="photos" /> 
 

 
    </div> 
 
</div>

+0

我需要这两张照片应该是圈子的左侧和右侧。与我给予的快照相同 – Nikunj

+0

@Nikunj但是,您的问题是关于围绕一个圆圈的问题,而没有提及任何照片? ...我会在一秒内为我的答案增加一个额外的元素。 – LGSon

+0

@Nikunj更新了我的答案,显示了一种方法 – LGSon

0

你可以做这样的:

<div class="row"> 
 
    <div class="col-md-5" style="background-color:pink;height:74px;"></div> 
 
    <div class="col-md-2 text-center"> 
 
    <img src="http://placehold.it/75x75" alt=""> 
 
    </div> 
 
    <div class="col-md-5" style="background-color:yellow;height:74px;"></div> 
 
</div>

这里是它的图像:

enter image description here

0

以下是您所要求的设计。复制下面的代码粘贴,并根据您的需要调整其他东西。

<div class="row"> 
    <div class="col-md-12 heading" style="background-color:#ff4940;height:74px;"> 
    <h2>Some text</h2> 
    </div> 
</div> 

<div class="blue-cirle-div"> 
    <h5 class="text-center">NY</h5> 
</div> 
<div class="row"> 
    <div class="col-md-12 middle" style="background-color:cyan;height:74px;"> 
    </div> 
</div> 
    <div class="box-container"> 
    <div class="box"></div> 
    <div class="box"></div> 

    </div> 
    </body> 

CSS这里 -

body{ 
    overflow-x:hidden; 
} 
.heading{ 
    display: flex; 
    justify-content: center; 
    align-items: center; 
} 

h2{ 
color:white; 
} 
.blue-cirle-div{ 
    background: none repeat scroll 0 0 #fff; 
    box-shadow:0 2px 5px rgba(0,0,0,0.16); 
    border-radius: 50%; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    height: 50px; 
    width:50px; 
    left: 50%; 
    margin: 0 auto; 
    position: absolute; 
    text-align: center; 
    top: 60px; 
    vertical-align: middle; 
    z-index:1; 
} 

.middle{ 
    margin-top:12px; 
} 

.box-container{ 
    display:flex; 
    justify-content:center; 
    align-self:center; 
    width:100%; 
} 

.box{ 
    display: flex; 
    justify-content:center; 
    align-self:center; 
    float:left; 
    box-shadow:0 2px 5px rgba(0,0,0,0.16); 
    margin: 0 15px; 
    width:200px; 
    height:200px; 
    position:relative; 
    top:-45px; 
    background:lightblue; 
} 
+0

谢谢bro ..您的css是完美的。 – Nikunj

+0

但是,我需要在这两个框的中心圈出一圈 – Nikunj

+0

您希望图片看起来像什么吗?我已经更新了CSS,请检查 –