Using Div's instead of anchors

帅比萌擦擦* 提交于 2019-12-13 00:42:39

问题


On my website, www.funpunks.com, in the top left of the page you'll see the navigation. I made this using fixed-size div's with background images, and using javascript to redirect "window.location = 'http://www.funpunks.com/' " etc.

But what about for users who have thier javascript disabled etc? I think I need to use anchor tags.

I need these anchor tags to display as block, and I need them to have a background image. Also each different link needs to have its own height/width and hover image.

Could it be done with using anchor tags instead of divs?

Thanks


回答1:


Why don't you still use anchors but display them as block-level elements with CSS?

a.some-class { display:block; }



回答2:


Definitely want to use <a>'s here. Go for the semantic markup every time. Just do style="display:block" and set the width, height, background image etc. For example, take a look at one of my sites here: http://krystalware.com/Products/SlickUpload/. The tabs on the left and top are both a's, styled properly.




回答3:


an A tag can have it's height / width set through CSS just like everything else.



来源:https://stackoverflow.com/questions/633129/using-divs-instead-of-anchors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!