Reputation: 401
I was trying to make this work but can't find a way. Here's the example I'm working on
HTML:
<ul>
<li><img></li>
<li><img></li>
</ul>
CSS
ul{position:relative;margin:0;padding:0;position:relative}
li{width:100px;height:100px;list-style-type:none;float:left;margin:2px;border: 1px solid #000}
img{}
li:hover{width:150px;height:150px;}
And here's the JSFiddle: http://jsfiddle.net/qw2W4/2/
How do I have the resizing of the li elements without moving all other elements?
I would like that to be made without use of JS if possible.
Upvotes: 1
Views: 9263
Reputation: 530
Change the css of li element to
li {
display: inline-block; //or block
width: 10px; // set a fixed width, 10px for example
}
That should work.
Upvotes: 0
Reputation: 8981
make this
ul {
margin: 0;
padding: 0;
}
li {
width: 100px;
height: 100px;
list-style-type: none;
float: left;
margin: 2px;
border: 1px solid #000;
position: relative;
}
li img {
position: absolute;
top: 0;
left: 0;
}
img {
}
li:hover img {
width: 150px;
height: 150px;
background-color: blue;
z-index: 1;
}
Upvotes: 1
Reputation: 2100
http://jsfiddle.net/qw2W4/4/
Check out the first element.
I inserted another element which has position: absolute
and gets scaled on hover.
Upvotes: 2