我有这个CSS代码:
#header-topbar {
width:100%;
height:120px;
padding-top:5px;
}
#header-right-content {
float:right;
margin-right:14%;
margin-top:20px;
font-size:20px;
text-align:right;
color:#000000;
}
#logo {
position: absolute;
float: left;
margin-left: 15%;
margin-top: 25px;
width: 360px;
height: 50px;
border:1px solid black;
}
#logo-small {
display:none;
}
然后这是我的响应式css:
@media screen and (max-width: 780px) {
#header-right-content {
display:none;
}
#logo {
display:block;
float: left;
margin-top: 25px;
width: 360px;
height: 50px;
border:1px solid black;
}
}
然后是 HTML:
<div id="header-topbar">
<div id="logo"><img src="images/logo.png" width="360" height="50" /></div>
<div id="header-right-content"><?php
if($_SESSION["customer_loggedin"] == 'yes')
{
echo 'Hello '.$_SESSION["customer_forename"].' '.$_SESSION["customer_surname"].' | <a href="/customer/index.php">Customer Centre</a> | <a href="/customer/logout.php">Logout</a>';
}
else
{
echo '<a href="/customer/login.php">Customer Login</a>';
}
?><br /><br />
Tel: <?php echo $main_phone_number; ?><br />Email: <?php echo $company_emailaddress_sales; ?></div> <!-- header-right-content -->
</div>
出于某种原因,随着屏幕变小,我无法让徽标显示在页面的中心。div #logo 不会在页面中居中。
有什么想法可能导致这种情况吗?