w3resource

CSS Properties: How hover over a division element to gradually change the width

Go to Exercise page

Solution:

HTML Code :

 <!DOCTYPE html>
  <html>
  <head>
  <title>How hover over a division element to gradually change the width</title>
  <style type="text/css">
  div {
    width: 100px;
    height: 100px;
    background: #00FFCC;
    transition: width 2s;
    -webkit-transition: width 2s;
}

div:hover {
    width: 200px;
}
  </style>
  </head>
  <body>
  <h1><strong>w3resource Tutorial</strong></h1>

  <div id="div">Web Development Tutorial</div>

  </body>
  </html>

Live Demo:

See the Pen transition-answer by w3resource (@w3resource) on CodePen.


See the solution in the browser

Supported browser

Firefox logo Chrome logo Opera logo Safari logo Internet Explorer logo
YesYesYesYesYes

Go to Exercise page

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.



Follow us on Facebook and Twitter for latest update.