0
我想通過CSS將搜索,徽標和購物車中心對齊,但我無法這樣做,如果我更改了邊距,所有對齊都會受到干擾。我如何將搜索,徽標和購物車對齊?如何通過CSS居中對齊菜單?
CSS:
.logo {
float:left;
width:370px;
margin-bottom: 10px;}
#search {
float:left;
width:235px;
text-align: left;
margin-bottom: 10px; }
#top-cart {
text-align: right;
float:right;
position: relative;
padding:1px 20px 5px 0;
background: url(images/shopping-bag.png) no-repeat top right;
width:280px;
line-height: 16px;}
#top-cart > a{
color:#818181;
}
HTML:
<div class="containerInner clearfix">
<header id="header">
<div id="search">
<div id="site-description"><?php bloginfo('description'); ?></div>
<?php get_search_form(); ?></div>
<div class="logo">
<?php $logoimg = etheme_get_option('logo'); ?>
<?php if($logoimg): ?>
<a href="<?php echo home_url(); ?>"><img src="<?php echo $logoimg ?>" alt="<?php bloginfo('description'); ?>" /></a>
<?php else: ?>
<a href="<?php echo home_url(); ?>" class="logo-text"><?php bloginfo('name'); ?></a>
<?php endif ;?>
</div>
<div class="cart-wrapper">
</div>
我試着使用margin-left:auto;
和margin-right:auto;
,但失敗了。
您的HTML代碼是PHP代碼,位於後端。這不是我們的瀏覽器收到的。請發佈HTML代碼 – FelipeAls
使用餘量:0 auto;在包裝中 – PRAH