Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

css - expand width in other direction

Tags:

I've got some icons that expands when I hover them:

  .icon   {       width: 128px;       height: 128px;       background: url(icons.png) no-repeat;       background-position: left top;       -webkit-transition: width .2s;   }   .icon.icon1:hover   {       width: 270px;       backgorund-position-x: -128px;   } 

When I hover an icon it's width is changed, so because of the -webkit-transition is will expand the icon. The way it expands is from left to right which is good for .icon1 and .icon2, but it should be the other way around (right to left) with .icon3 and .icon4.

like image 762
Gregor Menih Avatar asked Mar 19 '13 08:03

Gregor Menih


People also ask

How do I increase the width of the right side in CSS?

Easy! Add one line of code to the element that you wish to resize. float: right; This is basically the same as the accepted answer, but you don't have to mess with absolute positioning and then having a relative container.

How do I increase the width of a div from left to right?

Just position the content relative to the right edge to make it be hidden from the left. Depending on what you have in the div, you might need another container (div) inside it, that you style using position: absolute; right: 0 .

How do you increase left width in CSS?

The border-left-width property sets the width of an element's left border. Note: Always declare the border-style or the border-left-style property before the border-left-width property. An element must have borders before you can change the width.


1 Answers

Use position:absolute and set right:0 and top:0

    .icon{     width: 128px;     height: 128px;     background: url(icons.png) no-repeat red;     background-position: left top;     -webkit-transition: width .2s;     position:absolute;     top:0; right:0;  } .icon:hover{     width:250px } 

DEMO

like image 118
Sowmya Avatar answered Oct 30 '22 16:10

Sowmya