Click here to Skip to main content
15,887,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created images horizontally in div.when i apply border to images on hover,images are shakking.what i have to do?give suggestions
here is my code
XML
<html>
<head>
<style type="text/css">
#abc{
float:left;
border: dotted;


}
#abc:hover
{
border:1px solid pink;
}

.a
{
  padding-top: 100px;
    padding-bottom: 50px;
}
.b
{
 padding-top: 30px;
}
.c
{
 padding-top: 50px;
}
.d
{
 padding-top: 50px;
}tr {
width:auto;
    display: inline;
}
td{
text-align:center;
}
</style>

</head>
<body>
<div class="main">
<div class="a" vspace="20" >
<table><tr><td>

<img id="abc"  hspace="35"height="150"width="150"   src="image.jpg"/><br/>text1</td></tr>

<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"/><br/>text1</td></tr>
<tr><td>
<img id="abc"  hspace="35"height="150"width="150"src="image.jpg"/><br/>text1</td></tr>
<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"/><br/>text1</td></tr>
</table>
</div>
<div style="clear:both;"></div>

<div class="b" vspace="20" >
<table><tr><td>
<img id="abc"  hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc"  hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
</table>
</div>
<div style="clear:both;"></div>

<div class="c" vspace="20">
<table><tr><td>
<img id="abc"  hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc"  hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
</table>
</div>
<div style="clear:both;"></div>
<div class="d" vspace="20">
<table><tr><td>
<img id="abc"  hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc" hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
<tr><td>
<img id="abc"  hspace="35" height="150"width="150" src="image.jpg"><br/>text1</td></tr>
</table>
</div>

</div>
</body>
</html>
Posted

1 solution

You have used same id so many times so remove that and use class instead.
See the updated code:
CSS
.wrapper {
    border: solid 1px transparent;
    border-radius:4px;
    height: 100px;
    width: 100px;
    padding: 15px;
}

.wrapper img {
    border: dotted 1px #555;
    height: 100%;
    width: 100%;
}

.wrapper img:hover{
    border-color:pink;
}


-KR
 
Share this answer
 
v2
Comments
Hussain Javed 3-Oct-15 5:23am    
i have done what you say but,I want dotted border to image.on hover i want pink border.
i change my code as
.abc:hover
{
border:1px solid pink;
padding-bottom: 2px;
padding-top: 2px;
padding-left: 2px;
padding-right: 2px;
}
again images are shake
please refer this link
http://www.houseofblouse.com/start-designing
Krunal Rohit 3-Oct-15 5:31am    
If you can see in the given link, image itself has a dotted border.

-KR
Hussain Javed 3-Oct-15 5:37am    
ok.I removed id to images and place class to images.i apply your code images are shaking
here is my applied code
.abc{
float:left;
border:1px solid transparent;
}
.abc:hover
{
border:2px solid pink;
}
Hussain Javed 3-Oct-15 5:56am    
I want padding between image and border on hover.as you see in that link
I have use
.abc:hover
{
border:1px solid pink;
padding-top: 5px;
padding-bottom: 5px;
padding-right: 5px;
padding-left: 5px;
}
Krunal Rohit 3-Oct-15 6:14am    
Check the updated answer.

-KR

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900