我在将内容放入中心方面存在问题
.menuenglish {
overflow: hidden;
background-color: #3c769c;
font-family: Arial;
padding-left: 0px;
}
.menuenglish a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown1 .dropbtn {
cursor: pointer;
font-size: 13px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
}
.dropdown1-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown1-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

<div class="hidden-md hidden-lg visible-xs visible-sm">
<div class="menuenglish">
<a href="#">Main Deal </a>
<a href="#" title="E.E.E. Free">E.E.E. Free</a>
<a href="#" title="Perfumes">Perfumes</a>
<div class="dropdown1">
<button class="dropbtn" onclick="myFunction()">More+</button>
<div class="dropdown1-content" id="myDropdown">
<a href="#" title="Mobiles">Mobiles</a>
<a href="#" title="E-cards">E-cards</a>
</div>
</div>
</div>
</div>
&#13;
答案 0 :(得分:4)
从.menuenglish
制作弹箱,并使用justify-content: center
。
.menuenglish {
overflow: hidden;
background-color: #3c769c;
font-family: Arial;
padding-left: 0px;
display: flex;
justify-content: center;
}
.menuenglish a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown1 .dropbtn {
cursor: pointer;
font-size: 13px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
}
.dropdown1-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown1-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
<div class="hidden-md hidden-lg visible-xs visible-sm">
<div class="menuenglish">
<a href="#">Main Deal </a>
<a href="#" title="E.E.E. Free">E.E.E. Free</a>
<a href="#" title="Perfumes">Perfumes</a>
<div class="dropdown1">
<button class="dropbtn" onclick="myFunction()">More+</button>
<div class="dropdown1-content" id="myDropdown">
<a href="#" title="Mobiles">Mobiles</a>
<a href="#" title="E-cards">E-cards</a>
</div>
</div>
</div>
</div>
答案 1 :(得分:2)
希望我能正确理解您,但使用flexbox
是一种集中菜单内容的方法。
希望这有帮助。
.menuenglish {
overflow: hidden;
background-color: #3c769c;
font-family: Arial;
padding-left: 0px;
display: flex;
justify-content: center;
}
.menuenglish a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown1 .dropbtn {
cursor: pointer;
font-size: 13px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
}
.dropdown1-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown1-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
<div class="hidden-md hidden-lg visible-xs visible-sm">
<div class="menuenglish">
<a href="#">Main Deal </a>
<a href="#" title="E.E.E. Free">E.E.E. Free</a>
<a href="#" title="Perfumes">Perfumes</a>
<div class="dropdown1">
<button class="dropbtn" onclick="myFunction()">More+</button>
<div class="dropdown1-content" id="myDropdown">
<a href="#" title="Mobiles">Mobiles</a>
<a href="#" title="E-cards">E-cards</a>
</div>
</div>
</div>
</div>
答案 2 :(得分:2)
完全支持
IE
属性的第一个版本flex
是IE10
所以,我使用其他方式:
.menuenglish {
overflow: hidden;
background-color: #3c769c;
font-family: Arial;
padding-left: 0px;
text-align: center;<--------------Added
}
.menuenglish a ,.menuenglish .dropdown1 {
display: inline-block;
}
.menuenglish a {
float: left;<---------------Remove
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.menuenglish {
overflow: hidden;
background-color: #3c769c;
font-family: Arial;
padding-left: 0px;
text-align: center;
}
.menuenglish a ,.menuenglish .dropdown1 {
display: inline-block;
}
.menuenglish a {
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.dropdown1 .dropbtn {
cursor: pointer;
font-size: 13px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
}
.dropdown1-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
}
.dropdown1-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
<div class="hidden-md hidden-lg visible-xs visible-sm">
<div class="menuenglish">
<a href="#">Main Deal </a>
<a href="#" title="E.E.E. Free">E.E.E. Free</a>
<a href="#" title="Perfumes">Perfumes</a>
<div class="dropdown1">
<button class="dropbtn" onclick="myFunction()">More+</button>
<div class="dropdown1-content" id="myDropdown">
<a href="#" title="Mobiles">Mobiles</a>
<a href="#" title="E-cards">E-cards</a>
</div>
</div>
</div>
</div>
答案 3 :(得分:1)
你可以在menuenglish类中使用display:flex
.menuenglish {
overflow: hidden;;
display: flex;
justify-content: center;
}
工作正常