中心响应导航图标

时间:2016-06-27 01:35:27

标签: html css

有人能帮忙吗?

努力使这些图标居中并使它们响应屏幕的宽度。

随着屏幕宽度的改变,我试图让这些图标更接近 我一直试图给你的边距一个'%',因为你可以通过我的代码看到它“,这样它们会随着宽度缩小而彼此靠近但是它实际上并没有像我期望的那样出现。 !这看起来很简单,但我不能得到!欢呼的家伙

html, body {
  background-color:#B0B0B0;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  color: black;	
}
html {
  position: relative;
  min-height: 100%;
}
body {
  margin: 0 0 100px;
}
.navigationbar {
  height: 70px;
  width: 100%;
  background: black;
  border-bottom: solid 10px #1BD2E1;
  color: white;

}
#content {
  position: absolute;
  background-color: white;
  width: 800px;
  height: 100%;
  margin: auto;
  top: 300px;
  left: 0;
  bottom: 0;
  right: 0;
}
.logo-container {
  display: block;
  position: relative;
  left: 20%;
  width: 90%;
}
.blockicon {
  display: block;
  position: relative;
  width: 60px;
  height: 60px;	
  top: 45px;
  background: #A81D1F;
  border-radius: 15%;
  cursor: pointer;
  float: left;
  margin-left: 3%;
}
<div class="navigationbar">
  <div class="logo-container">
    <div class="blockicon"></div>
    <div class="blockicon"></div>
    <div class="blockicon"></div>
    <div class="blockicon"></div>
    <div class="blockicon"></div>
    <div class="blockicon"></div>
  </div></div>
<div id="content"></div>

1 个答案:

答案 0 :(得分:0)

您可以使用flexible boxes

这是一个例子。

如果你想让盒子缩小&#34;当没有足够的地方时,给他们一个保证金。在需要时,它们会变小以保留此边距。

&#13;
&#13;
html, body {
  background-color:#B0B0B0;
  margin:0;
  padding:0;
  font-family: sans-serif;
  color: black;	
}
html {
  position: relative;
  min-height: 100%;
}
body {
  margin: 0 0 100px;
}
.navigationbar {
  height: 70px;
  width: 100%;
  background: black;
  border-bottom: solid 10px #1BD2E1;
  color: white;

}
#content {
  position: absolute;
  background-color: white;
  width: 800px;
  height: 100%;
  margin: auto;
  top: 300px; left: 0; bottom: 0; right: 0;

}
.logo-container{
  display: flex;
  flex-direction: row;
  position: relative;
  width: 100%;
  justify-content: space-around;
}
.blockicon {
  position: relative;
  width: 60px;
  height: 60px;	
  top: 45px;
  background:#A81D1F;
  border-radius: 15%;
  cursor: pointer;
  margin: 0 3%;
}
&#13;
<div class="navigationbar">
  <div class="logo-container" >
    <div class="blockicon">
    </div>
    <div class="blockicon">
    </div>
    <div class="blockicon">
    </div>
    <div class="blockicon">
    </div>
    <div class="blockicon">
    </div>
    <div class="blockicon">
    </div>
  </div>
</div>
<div id="content">
</div>
&#13;
&#13;
&#13;

您可能必须为旧浏览器添加前缀。 Current support is ~95% with prefixes and ~80% without prefixes