CSS - HTML - How to align images properly across the page -
i want make images aligned if can appreciated images 100% same size not problem
.box { float: left; width: 20%; padding-bottom: 20%; } .top-left { position:absolute; top: 10px; left: 10px; width: 50%; overflow: hidden; } .top-right { position:absolute; top: 10px; right: 10px; width: 50%; overflow: hidden; } .bottom-left { position:absolute; bottom: 10px; left: 10px; width: 50%; overflow: hidden; } .bottom-right { position:absolute; bottom: 10px; right: 10px; width: 50%; } @media screen , (max-width : 480px) { .box { width: 100%; } .box a{ position: relative; } .top-left, .top-right, .bottom-left, .bottom-right { width:100%; } }
<!doctype html> <html> <head> <title>deluzens</title> <link rel="stylesheet" href="main.css" media="screen" title="no title" charset="utf-8"> <link href="main.css" rel="stlesheet" type="text/css"> <style> .wrap { overflow:hidden; } </style> </head> <body bgcolor="black"> <div class="section-links"> <div class="wrap"> <div class="box"> <a href="teams.html" class="top-left"> <img style="width: 100%;" style="height: 100%" src="icon1.jpg" alt=""> </a> </div> <div class="box"> <a href="store.html" class="top-right"> <img style="width: 100%;" style="height: 100%" src="icon2.jpg" alt=""> </a> </div> <div class="box"> <a href="sponsors.html" class="bottom-left"> <img style="width: 100%;" style="height: 100%" src="icon4.jpg" alt=""> </a> </div> <div class="box"> <a href="aboutus.html" class="bottom-right"> <img style="width: 100%;" style="height: 100%" src="icon3.jpg" alt=""> </a> </div> </div> </div> </body> </html>
so if can see @ top pointy end isn't touching other 1 same 2 sides
kind regards creepyc appreciated
you're setting height , width of <a>
elements 50%
you're positioning them 10px
each edge, means overlap.
you can use css calc()
size images 10 pixels less 50% compensate:
width: calc(50% - 10px);
(note spaces important, don't leave them out).
calc()
relatively new, check http://caniuse.com/#feat=calc browser support if it's concern.
Comments
Post a Comment