2013-10-06 33 views
0

我写了html代码,我遇到了问题。我添加了一个链接到一个图像,但这个图像有一个填充。所以现在填充是链接和图像的一部分。我可以做些什么吗?只有图像被链接?填充是链接的一部分

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="UTF-8"> 
     <title>Just testing</title> 
     <style type=text/css> 
      .design {background-color: orange; padding: 50px; border: thick double red; margin: 500} 
      .design2 {background-color: yellow; padding: 10px 100px; border: thick groove red; margin: 10} 
      .centered {text-align: center} 
      #blink {text-decoration: underline overline;;color: red} 
     </style> 
    </head> 
    <body style="background-color: lightgray"> 
     <h1 class="centered design2">This is <span style="color:red">MY</span> site :D:D</h1> 
     <a href="http://upload.wikimedia.org/wikipedia/commons/8/83/Neugierige-Katze.JPG"> 
     <p class="centered"><img class="design" style="align: center" src="Neugierige-Katze.jpg" alt="tolle Katze" width="500" height="325"> 
     </p> 
     </a> 
     <p class="centered">Cat the Cat is <span id="blink"> WATCHING YOU</span> 
     </p> 
     <p class="centered"> 
      <audio controls> 
       <source src="Cat_Meow_2-Cat_Stevens-2034822903.mp3" type="audio/mpeg"> 
       <source src="Cat_Meow_2-Cat_Stevens-2034822903.ogg" type="audio/ogg"> 

    </body> 
</html> 

我很感谢任何能够帮助我的人。所有的

`

回答

0

一种方式做到这一点http://jsbin.com/OdoSIme/1/

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
     <meta charset="UTF-8"> 
     <title>Just testing</title> 
     <style type=text/css> 
      .design {background-color: orange; padding: 50px; border: thick double red; margin: 500} 
      .design2 {background-color: yellow; padding: 10px 100px; border: thick groove red; margin: 10} 
      .centered {text-align: center} 
      #blink {text-decoration: underline overline;color: red} 
     </style> 
    </head> 
    <body style="background-color: lightgray"> 
    <h1 class="centered design2">This is <span style="color:red">MY</span> site :D:D</h1> 

    <p class="centered design" style="margin:0 auto; display: table;"> 
     <a href="http://upload.wikimedia.org/wikipedia/commons/8/83/Neugierige-Katze.JPG"> 
     <img style="align: center" src="http://wallpapersfor.me/wp-content/uploads/2012/02/cute_cat_praying-1280x800.jpg" alt="tolle Katze" width="500" height="325"> 
     </a> 
    </p> 

    <p class="centered">Cat the Cat is <span id="blink"> WATCHING YOU</span></p> 
    <p class="centered"> 
     <audio controls> 
      <source src="Cat_Meow_2-Cat_Stevens-2034822903.mp3" type="audio/mpeg"/> 
      <source src="Cat_Meow_2-Cat_Stevens-2034822903.ogg" type="audio/ogg"/> 
     </audio> 
    </body> 

+0

这对我工作得很好,但到底是什么的属性附加伤害:风格=“保证金:0汽车;显示:表,实际上代表 – New2HTML

+0

这是一种居中的方式,因为我给它设计类,否则它会在左边 –

+0

边界属性中的自动值有什么不同?为什么使用值0? – New2HTML

0

首先不要把像 “P” 块元素成一个内联elment如 “a”。 为什么不把“a”标签放在“p”标签中? 使用余量而不是填充。

这是我的结果:

[...] 
    <style type=text/css> 
     .design {background-color: orange; margin: 50px; border: thick double red; margin: 500} 
     .design2 {background-color: yellow; padding: 10px 100px; border: thick groove red; margin: 10} 
     .centered {text-align: center} 
     #blink {text-decoration: underline overline;;color: red} 
    </style> 
[...] 
    <p class="centered"> 

     <a href="http://upload.wikimedia.org/wikipedia/commons/8/83/Neugierige-Katze.JPG" class="design"><img style="align: center" src="Neugierige-Katze.jpg" alt="tolle Katze" width="500" height="325"></a> 

    </p> 

    [...] 

作品为我好

编辑:好吧,保证金也是可能的。只要删除跨度,并将图像边缘。

0

填充被认为是元素的一部分。如果您不想要这种行为,请改用保证金。