开发者

Clickable logo - Div as link

开发者 https://www.devze.com 2023-02-14 15:59 出处:网络
In the header of my website I have an image. I want this image to become a link. Currently I display the image as a background for a DIV element:

In the header of my website I have an image. I want this image to become a link. Currently I display the image as a background for a DIV element:

.myheader
{  
  font-weight: bolder;
  text-transform: uppercase; 
  text-开发者_高级运维align: justify;
  background-image: url(images/back.png);
  background-repeat: no-repeat;
  background-position: top center;
  margin: auto;  
  width: 700px;
  height: 100px; 
}

I want the whole DIV to be clickable as a link to the homepage.

UPDATE Okay, looking at Stack Overflow with FireBug I can see that their logo is not a background but rather an <img> element. Seems that this is the only option.


divs cannot be made into links, they are structural elements,

The only way you could go about this is by creating a hyperlink element a inside the logo div and assigning it a class myClass then in a CSS give the following:

a.myClass {
width:700px;
height:100px;
display:block;
}

This should give the impression that the div is clickable by making the a element the same width and height as the logo div


a.in-question {
    display:block;
    width:100%;
    height:100%;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号