I have tried many solutions posted on the web and none seem to solve my problem when the width goes larger than 1920 px. The things I have tried include, but not limited to:
- http://www.w3.org/Style/Examples/007/center.en.html
- How to center image in a div horizontally and vertically
- How to make an image center (vertically & horizontally) inside a bigger div
I have even tried the good old trick of wrapping the div
in a text element and just aligning it to center but it was no good. Before I move on to code here are some pictures to visualize the problem.
Here is how it looks like when width <= 1920px (ignore the minor alignment issues on bottom of the page)
And here is what happens when I expand the screen. Everything except that row aligns perfectly.
Relevant Code:
HTML:
<div class="displaylayer">
<div class="container">
<div class="row">
<div class="col-md-1 col-lg-1">
<img src="images/button2.png" class="clickthisleft" />
</div>
<div class="col-md-5 col-lg-7">
<div id="displayframe">
<div id="display">
<img id="mainimage" src="images/col1.jpg" height="420" width="960" />
</div>
</div>
</div>
<div class="col-md-1 col-lg-1">
<img src="images/button2.png" class="clickthisrigth"/>
</div>
</div>
</div>
</div>
CSS:
.container{
width: 100%;
}
.row{
width: 100%;
}
.displaylayer {
width: 100%;
display: block;
margin-left: auto;
margin-right: auto;
}
.displaylayer .row div{
margin-left: 5%;
}
#display{
width: 960px;
height: 420px;
overflow: hidden;
margin-left: 0%;
margin-right: auto;
border-radius: 4px;
background-color: white;
}
.displaylayer .container{
width: 100%;
}
.displaylayer .row{
width: 100%;
margin-left: 200px;
}
.clickthisleft, .clickthisrigth{
margin-top: 130px;
width: 70px;
height: 200px;
}
.clickthisrigth{
margin-left: 45%;
}
.clickthisleft{
margin-left: 100%;
}
Any suggestions are appreciated. Even if it takes to up to a certain width, I can manually arrange for the rest. Every automated pixel means less manual optimization which is always good.