html - How to set background color for a boxed link? -


i have link on website borders.

html:

<p id="hero4"><a href="menu.html">explore our menu</a></p> 

css:

#hero4 { border:1px solid white; border-radius:5px; width:150px; height:30px; margin:auto;} 

i'd entire "box" turn grey when user hovers on it, "create yours" button on starbucks website. right now, have:

#hero4 a:hover { background-color:grey;} 

but small rectangular area around text turns grey. how can change css entire area within border changes color?

you can move style <p> <a> tag, , set display:block;.

#hero4 {    border: 1px solid blue;    border-radius: 5px;    width: 150px;    height: 30px;    margin: auto;    display: block; /*added*/    text-align: center; /*extra: center text horizontally*/    line-height: 30px; /*extra: center text vertically*/  }  #hero4 a:hover {    background-color: grey;  }
<p id="hero4"><a href="menu.html">explore our menu</a></p>


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -