我已经尝试了很多浮动组合,显示:内联块和位置:相对或绝对。
似乎无法在网站的移动版本的同一行的任一侧获取菜单栏和徽标。
以下是网站:the post of Eric Lippert
<div class="main-header bg-main-header" id="header_top">
<div class="main-center">
<!-- left content on header -->
<div class="f-left f-left-all">
<!-- fix logo middle -->
<table class="fix-logo">
<tr>
<td>
<a href="<?php echo home_url()?>" class="logo"><img src="<?php echo $website_logo[0];?>" alt="<?php echo $general_opts->get_site_title(); ?>" /></a>
</td>
<td>
<div id="hide-show-button" style="margin-top: 30px;"></div>
</td>
</tr>
</table>
<div id="hide-show-button"></div>
<div class="slogan"></div>
</div>
这是CSS代码:
#hide-show-button {
float: right !important;
background: url("images/menu-icon-dna.png") no-repeat right top/ auto 30px;
background-repeat: no-repeat;
cursor: pointer;
position: absolute;
height: 50px !important;
width: 70px !important;
margin-bottom: 30px !important;
margin-top: 30px !important;
z-index: 999;
}
任何帮助表示感谢。
答案 0 :(得分:1)
解决方案:使用display: flex;
对于跨浏览器支持:使用
display: inline-block;
答案 1 :(得分:0)
我相信你正在采用这样的解决方案,将显示隐藏按钮放在右边:
.fix-logo{
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
}
#hide-show-button {
border: 1px solid #121256;
border-radius: 3px;
background: #7878bc;
cursor: pointer;
padding: 5px 10px;
color: white;
}
<div class="main-header bg-main-header" id="header_top">
<div class="main-center">
<div class="f-left f-left-all">
<div class="fix-logo">
<a href="#" class="logo"><img src="http://www.alicejoeconsulting.com/wp-content/uploads/2015/06/alice_logo2.png" alt="" /></a>
<div id="hide-show-button">Button</div>
</div>
<div class="slogan"></div>
</div>
</div>
</div>