0

我有一个包含一个包含 h1 的锚标记的部分,h1 有一个背景图像,当我将鼠标悬停在 h1 背景图像上时,位置会发生变化以模仿翻转,但是,翻转在 h1 右侧的右侧也是活动的它尝试向右悬停,我试图摆脱边距和填充无济于事。

这是现场直播

html

<!DOCTYPE html>
<html>
<head>
    <title>Portfolio of Anders Kitson</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <!--[if lt IE 9]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="css/normalize.css">
    <link rel="stylesheet" href="css/styles.css">
    <script type="text/javascript" src="//use.typekit.net/lfr7txf.js"></script>
    <script type="text/javascript">try{Typekit.load();}catch(e){}</script>
</head>
<body>
<div id="container">
<header>
<h1>ASK</h1>
<h2>Anders Samuel Kitson, front end web developer.</h2>
</header>
<section id="siteThumbs"><!--not sure if this is appropriate use of the section tag-->
<a href="#"><h1>Springmethod.com</h1></a>
</section>
</div>
</body>
</html>

css

/*variables*/
/*shared styles*/
#container {
  width: 960px;
  max-width: 90%;
  border: solid 0px #000;
  margin: auto; }

header h1 {
  background: url("../images/ask.gif");
  width: 97px;
  height: 96px;
  text-indent: -9000px; }
header h2 {
  font-family: "brandon-grotesque",sans-serif;
  font-weight: 300;
  font-size: 2.5em; }

#siteThumbs h1 {
  background: url("../images/springmethod.jpg");
  width: 321px;
  height: 241px;
  text-indent: -9000px;
  padding: 0;
  margin: 0; }

#siteThumbs a:hover h1 {
  background: url("../images/springmethod.jpg") 0 -241px no-repeat; }

/*media queries*/
/* Smartphones (portrait and landscape) */
@media only screen and (min-width: 0px) and (max-width: 767px) {
  header h2 {
    font-size: 1.5em; } }
4

1 回答 1

1

h1您可以在 a 内嵌套div,设置div' 的宽度以达到所需的效果。

<a href="#">
    <div style="width: 100px">
        <h1>Springmethod.com</h1>
    </div>
</a>
于 2012-11-24T06:31:01.873 回答