Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i'm new to programming and have been looking all day for this, but can't seem to find the answer. How do I divide 4 pictures on a row? Just like this but with four pictures:


https://codepen.io/bradtraversy/pen/dJzzdB


example:

(Image)...........(image)............(image)............(image)

(button)...........(Button)..........(button)...........(button)

Thank you :)

What I have tried:

HTML



<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Meg</title>
    <link rel="stylesheet" href="masterp2.css">
  </head>
  <body>
    <div class="container">


      <div class="split left">
        <button type="button" name="btnl">Mer info</button>
      </div>


      <div class="split right">
        <button type="button" name="btnr">Mer info</button>
      </div>


      <div class="split rightmiddle">
        <button type="button" name="btnm">Mer info</button>
      </div>
    </div>

    <div class="split leftmiddle">
      <button type="button" name="btnlm">Mer info</button>
    </div>
  </div>

  </body>
</html>


html, body{
  margin: 0;
  padding: 0;
  
}

button{
  background: none;
  color: #ccc;
  width: 150px;
  height: 80px;
  border: 1px solid #338033;
  font-size: 18px;
  border-radius: 4px;
  transition: .6s;
  overflow: hidden;
}

button:hover{
  background: #338033;
  cursor: pointer;
  outline: none;

}

.split.left button{
  top: 50%;
  position: absolute;
  left: 25%;
  transform: translate(-15%, -50%);
}


.split.right button{
  top: 50%;
  position: absolute;
  right: 25%;
  transform: translate(-15%, -50%);
}

.split.middle button{
  top: 50%;
  position: absolute;
  right: 25%;
  transform: translate(-25%, -50%);
}

.split.leftmiddle button{
  top: 50%;
  position: absolute;
  left: 25%;

}


.split{
  width: 25%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  top: 0;
  overflow-x: hidden; 
}

.split.left{
  left: 0;
  background: url('https://image.ibb.co/m3ZbRb/programmer.png') center center no-repeat;
  background-size: cover;
}

.split.right{
  right: 0;
  background: url('https://images.pexels.com/photos/860564/pexels-photo-860564.jpeg?auto=compress&cs=tinysrgb&h=650&w=940')  center no-repeat;
  background-size: cover;
}

.split.middle{
  right: 30;
  background: url('https://images.pexels.com/photos/1133957/pexels-photo-1133957.jpeg?auto=compress&cs=tinysrgb&h=650&w=940') center center no-repeat;
  background-size: cover;
}

.split.leftmiddle{
  left: 25;
  background: url('https://images.pexels.com/photos/414391/pexels-photo-414391.jpeg?auto=compress&cs=tinysrgb&h=350') center no-repeat;
  background-size: cover;
}
Posted
Updated 18-Nov-18 21:22pm

1 solution

I'm using liveweave[^]
it should work. In case you face any problem feel free to ask me.
This would be my approach..

HTML
HTML
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Meg</title>
    <link rel="stylesheet" href="masterp2.css">
  </head>
  <body>
    <div class="container">
      <div class="split left">
        <button type="button" name="btnl">Mer info</button>
      </div>
      <div class="split right">
        <button type="button" name="btnr">Mer info</button>
      </div>
      <div class="split rightmiddle">
        <button type="button" name="btnm">Mer info</button>
      </div>
      <div class="split leftmiddle">
        <button type="button" name="btnlm">Mer info</button>
      </div>
    </div>
  </body>
</html>


CSS
CSS
html, body{
  margin: 0;
  padding: 0;
}
*
{
  box-sizing: border-box;
}
.container
{
  width: 100%;
  display: block;
}
button{
  background: none;
  color: #ccc;
  width: 150px;
  height: 80px;
  border: 1px solid #338033;
  font-size: 18px;
  border-radius: 4px;
  transition: .6s;
  overflow: hidden;
}
button:hover{
  background: #338033;
  cursor: pointer;
  outline: none;
}
.left button, .right button, .rightmiddle button, .leftmiddle button{
  top: 50%;
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
}
.split{
  width: 25%;
  height: 200px;
  overflow: hidden;
  position: relative;
  top: 0;
  overflow-x: hidden;
  float: left;
}
.left{
  background: url('https://image.ibb.co/m3ZbRb/programmer.png') center center no-repeat;
}
.right{
  background: url('https://images.pexels.com/photos/860564/pexels-photo-860564.jpeg?auto=compress&cs=tinysrgb&h=650&w=940')  center no-repeat;
}
.rightmiddle{
  background: url('https://images.pexels.com/photos/1133957/pexels-photo-1133957.jpeg?auto=compress&cs=tinysrgb&h=650&w=940') center center no-repeat;
}
.leftmiddle{
  background: url('https://images.pexels.com/photos/414391/pexels-photo-414391.jpeg?auto=compress&cs=tinysrgb&h=350') center no-repeat;
}
.left, .right, .rightmiddle, .leftmiddle
{
  background-size: cover;
}


If you don't have other buttons on the page doing this .left button, .right button, .rightmiddle button, .leftmiddle button is a lot of work you should rather use button only.
Remember to rate if that helped
 
Share this answer
 
v2

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