2013-08-03 50 views
1

我正在創建我的網站found here,我在頁面頂部添加了自己的徽標。 由於本網站是一個手機優化網站,我想添加徽標,以便正確縮放到相應的視口(設備屏幕大小)。使用95%標記無法正常工作的圖像

我已經在我的CSS文件中使用此代碼來實現這一點:

.logo{ 
     width: 75%; 
     height: 10%; 
} 

我的標誌存儲在header.php,幷包含所有相應的頁面。但是,該徽標在主頁上看起來不錯,但是當單擊其中一個導航選項卡以調出list.php頁面時,它看起來並不正確。

header.php ------------

<html> 
<head> 
<meta content="yes" name="apple-mobile-web-app-capable" /> 
<meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" /> 
<meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /> 
<link href="css/style.css" type="text/css" rel="stylesheet" /> 
<link type="text/css" rel="stylesheet" href="other.css" /> 

</head> 
<body width="100%"> 


<p align="center"><img src="http://www.xclo.co.uk/logomobi.png" onclick="history.go(-1);" class="logo" border="0" width="100%" /> 


<div class="ribbon"><div class="ribbon-stitches-top"></div><strong class="ribbon-content"><h1><a href="index.php" style="color:#000000;">Home</a> - <a href="search.php" style="color:#000000;">Search</a> - More</h1></strong><div class="ribbon-stitches-bottom"></div></div></p> 


<br /><br /><br /><br /> 

</p> 


</body> 
</html> 

的CSS是:

body{ 
    background-color:#dff7c8; 
} 

@font-face { 
    font-family: 'CustomFont'; 
    src: url('fonts/fh_ink.eot'); /* For Internet Explorer 6+ */ 
} 
@font-face { 
    font-family: 'CustomFont'; 
    src: url('fonts/fh_ink.ttf'); /* For non-IE browsers */ 
} 

a:link{ 
     color:black; 
     text-decoration:none; 
} 

.border { 
     width: 90%; 
     height: auto; 
     Margin-left:auto; 
     Margin-right:auto; 
     background-color:#c3f495; 
     border: 5px ridge #009900; 
     border-radius: 20px 50px 20px 20px; 
     box-shadow: 10px 10px 10px rgba(0,0,0,0.55); 

} 

.title { 
    font-family: 'CustomFont'; 
     text-align: center; 
     font-size: 2.5em; 
     color:#000000; 
     text-shadow: #999 2px 2px 4px; 
} 


.content { 
     font-size: 15px; 
     color:#000000; 
} 

.search { 
     width: 24em; 
     height:3em; 
     border: 5px solid #009900; 
     border-radius: 10px; 
    position: relative; 
     box-shadow: 2px 2px 2px 2px #A4A4A4; 
     font-size: 20px; Position:relative; 
} 

/* (portrait) ----------- */ 
@media screen and (orientation:portrait){ 


.logo{ 
     position:relative; 
     width: 75%; 
     height: 10%; 
} 

.go { 
    position:relative; 
    float: right; 
    margin: 0px 0px 0px; 
    border: 0px; 
    background-color: transparent; 
} 


.inlay{ 
    position:absolute; 
    top:-15px; 
    left:-15px 
} 

.img { 
    position:relative; 
    width:201px;  
    height:81px; 
    background-color: transparent; 
} 

.img2 { 
    position:relative; 
    border-radius:20%; 
    width:201px;  
    height:81px; 
    background-color: transparent; 
} 

.img3 { 
    position:relative; 
    width:150px;  
    height:81px; 
    background-color: transparent; 
} 

.img4 { 
    position:relative; 
    width:201px;  
    height:150px; 
    background-color: transparent; 
} 

.appimg { 
    position:relative; 
    width:20%;  
    height:20%; 
    background-color: transparent; 
} 

.drapp { 
    position:relative; 
    width:35%;  
    height:15%; 
    background-color: transparent; 
} 

.appstoreimg { 
    position:relative; 
    width:110px;  
    height:40px; 
    background-color: transparent; 
} 


.divider { 
    border-top: 3px dashed #009933; 

} 

li.android, 
li.iphone, 
li.ipad{ 
    display:none; 
} 

body.android .android, 
body.iphone .iphone, 
body.ipad .ipad{ 
    display:block; 
} 

} 



/*(landscape) ----------- */ 
@media screen and (orientation:landscape){ 

.go { 
    position:relative; 
    float: right; 
    height:90px; 
    width:90px; 
    margin: 0px 0px 0px; 
    border: 0px; 
    background-color: transparent; 
} 


.inlay{ 
    position:absolute; 
    top:-15px; 
    left:-15px 
} 


.img { 
    position:relative; 
    width:211px;  
    height:81px; 
    background-color: transparent; 
} 

.img2 { 
    position:relative; 
    width:211px;  
    height:81px; 
    background-color: transparent; 
} 

.img3 { 
    position:relative; 
    width:150px;  
    height:81px; 
    background-color: transparent; 
} 

.img4 { 
    position:relative; 
    width:211px;  
    height:160px; 
    background-color: transparent; 
} 


.appimg { 
    width:15%;  
    height:8%; 
    background-color: transparent; 
} 

.drapp { 
    position:relative; 
    width:25%;  
    height:30%; 
    background-color: transparent; 
} 

.appstoreimg { 
    position:relative; 
    width:220px;  
    height:80px; 
    background-color: transparent; 
} 

.logo{ 
     position:relative; 
     width: 75%; 
     height: 10%; 
} 

.divider { 
    border-top: 3px dashed #009933; 

} 

li.android, 
li.iphone, 
li.ipad{ 
    display:none; 
} 

body.android .android, 
body.iphone .iphone, 
body.ipad .ipad{ 
    display:block; 
} 

} 

list.php ------------

<?php 

include_once('include/connection.php'); 
include_once('include/article.php'); 

$article = new storearticle(); 

$articles = $article->fetch_all(); 

?> 

<html> 

<head> 
<title>xclo mobi</title> 
<link rel="stylesheet" href="other.css" /> 
</head> 

<body width="100%"> 
<?php include_once('header.php'); ?> 


<div class="container"> 
<h6><div align="center" class="title" style="color:#618050;"><b><u><?PHP echo "category = ", htmlspecialchars($_GET['id']); ?></b></u></h6></div> 


    <?php foreach ($articles as $article) { 
    if ($article['promo_cat'] === $_GET['id']) { ?> 


<div class="border"> 
<a href="single.php?id=<?php echo $article['promo_title']; ?>" style="text-decoration: none"> 
<img src="<?php echo $article['promo_image']; ?>" border="0" class="img" align="left"><br /> 


<a href="<?php echo $article['promo_link']; ?>" target="_blank"><img alt="" title="" src="GO.png" height="50" width="50" align="right" /></a> 
<br /><br /><br /><br /> 
    <?PHP echo '<div class="title">' . $article['promo_title'] . '</div>'; ?> 
<br /> 

<font class="content"><em><center><?php echo $article['promo_content']; ?></center></em></font> 

</div><br/><br /> 

      </a> 

<?php } } ?> 

</div> 
<?php include_once('footer.php'); ?> 
</body> 

</html> 

有人請指導我在正確的方向嗎?謝謝。

+0

DESKTOP FireFox沒有問題。 ;)我錯過了「移動」部分! – AmazingDreams

+0

嗨。 AmazingDreams。你在看哪裏? –

+0

@KevHopwood你使用什麼瀏覽器?什麼OS? – 1234567

回答

1

有幾種方法可以嘗試。

您最初的徽標尺寸爲1,000px × 400px (scaled to 743px × 297px)

我建議使用此爲您所有的CSS類(.logo)

width:100%; max-width:743px; max-height:297px; 

我使用的東西來影響和它精美的作品。

您也可以嘗試:

<img style="-ms-interpolation-mode: bicubic; width:100%;" border=0 alt="LOGO" align=middle src="your_image.xxx"> 

這是我用一個客戶的網站的另一種方法,並使用它很好地呈現了較大的一1800px寬的圖像以及小iPhone屏幕,會自動調節到屏幕寬度,而不用擔心高度屬性。

+0

嗨弗雷德。即時通訊我正確地說,這個代碼'LOGO'不需要CSS? –

+0

@KevHopwood Hi Kev。 「onclick =」history.go(-1);「'可能屬於你的'href'而不是'img'。如果'70%'和'onclick =「history.go(-1);」'適合你,請試試看,但這是一般的想法。 –

+0

我有,它創造奇蹟 –

0

您必須移除寬度規則或高度規則以保持圖像比例。 你想要它是高度的10%還是寬度的75%?

而且從內嵌HTML刪除

width="100%" 

。將所有樣式規則保留在外部CSS中。

+0

嗨。你能解釋一下你的意思嗎? –

+0

更新了我的答案。 – Whistletoe

+0

我的列表和標題頁上的唯一寬度=「100」是主體寬度。他們兩人現在已被刪除,但仍然無效。 –