Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
HTML and CSS for gallery image border

I want create this type gallery. I have multiple images in it. So when I hover on it then images should changes automatically. Now I'm facing one issue i.e. How to add two borders like this using css or any other style-sheet.

image

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

It can be done with three elements. One element is the image itself, and it has a tiny 1px white border. Then there are two elements behind the image that have grey background and also white border.

Look at this example, pretty much the same, just change the div with class image for an actual img element and invert the positioning and you are ready to go.

.wrapper {
  position: relative;
}

div {
  width: 100px;
  height: 100px;
  background: #000;
  border: 1px solid #FFF;
  position: absolute;
}

.first {
  left: 5px;
  top: 5px;
  z-index: -1;
  background-color: #777;
}

.second {
  left: 10px;
  top: 10px;
  z-index: -2;
  background-color: #AAA;
}
<div class="wrapper">
  <div class="first"></div>
  <div class="second"></div>
  <div class="image"></div>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

You can add some box-shadow together. The first one is gray. The second one is white as a border with a one-pixel movement than the previous.

body{
background:#efefef;
}
.wrapper {
  position: relative;
  padding:10px;
}

.image {
  width: 100px;
  height: 100px;
  background: #000;
  border: 1px solid #FFF;
  position: absolute;
  box-shadow: 5px -5px 0 gray,6px -6px 0 white,11px -11px 0 lightgray,12px -12px 0 white;
}
<div class="wrapper">
  <div class="image"></div>
</div>

about 4 years ago · Juan Pablo Isaza Report

0

try this

<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color:black;
}
.imageContainer{
display:inline-block;
position:relative;
width:100px;
height:100px;
top:200px;
left:200px;
padding:50px;
background: url("https://media.cntraveller.com/photos/611bf0b8f6bd8f17556db5e4/1:1/w_2000,h_2000,c_limit/gettyimages-1146431497.jpg") no-repeat center center/cover;
}

.divOne{
position:absolute;
border-top:3px solid grey;
border-right:3px solid grey;

width:100%;
height:100%;
top:-6px;
left:6px;
z-index:-1;
}

.divTwo{
position:absolute;
border-top:3px solid grey;
border-right:3px solid grey;

width:100%;
height:100%;
top:-10px;
left:10px;
z-index:-1;
}
</style>
</head>
<body>

<div class="imageContainer">

<div class="divOne"></div>
<div class="divTwo"></div>
</div>
</body>
</html>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!