I've created some full-width divs containing images and text to exposure products. It did take a lot of trial and error (I do not have any kind of education).
However, it feels a bit clumsy and i'm starting to wonder if i could have done it any other way that might been easier or even better.
The way I set it up was to try having the text as close to the middle of the screen as possible. To have diversity between the exposures i set every other to be left/right. I also added srcset so it would look good, and load better on smaller devices.
So I'm thinking, could I have done this any other way? This is only for the sake of learning new things.
For example, could I have done the heading better with the lines above and below the H2-tag? Cause when I'm having longer titles, the lines are not centered.
And on some parts of the image the link becomes unclickable (I think it is because of how the div is set up).
.advertheading {
font-size: 20px;
line-height: 100px;
display: inline-block;
position: relative;
}
.ad-col-lg {
position: relative;
width: 100%;
height: auto;
-moz-column-count: 1;
-webkit-column-count: 1;
column-count: 1;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
}
.ad-col-lg img {
max-width: 100%;
display: block;
height: auto;
border: 0;
}
.ad-col-cont-lg {
position: absolute;
top: 25%;
left: 15%;
z-index: 0;
padding: 0;
padding: 1.2em;
font-size: .5em;
text-align: right;
width: 35%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
overflow: hidden;
}
.ad-col-cont-lg p {
font-family: 'Lato';
font-size: 17px;
color: #aaaaaa;
line-height: 22px;
padding-bottom: 20px;
}
.ad-col-cont-lg h2:before {
content: '';
border-top: 1px solid #383a4f;
position: absolute;
width: 30px;
left: 35%;
top: 15px;
}
.ad-col-cont-lg h2:after {
content: '';
border-bottom: 1px solid #383a4f;
position: absolute;
width: 30px;
left: 35%;
bottom: 15px;
padding-bottom: 20px;
}
._s-m-r {
top: 30%;
left: 65%;
}
._s-m-l {
top: 30%;
left: 0%;
}
.adcol-lg-left {
top: 25%;
left: 50%;
text-align: left;
}
.advert_button,
a.advert_button,
input.advert_button[type="submit"],
input.advert_button[type="button"] {
background-color: rgba(255, 255, 255, 0) !important;
color: #383a4f;
border: 1px solid rgba(56, 58, 79, 1.0);
padding: 5px 10px;
text-align: center;
cursor: pointer;
font-family: 'PT Sans Narrow';
font-size: 14px;
display: block;
margin: 0 auto;
-webkit-transition: all 200ms ease 0s;
-moz-transition: all 200ms ease 0s;
-ms-transition: all 200ms ease 0s;
-o-transition: all 200ms ease 0s;
transition: all 200ms ease 0s;
-webkit-appearance: none;
-webkit-border-radius: 0px;
-khtml-border-radius: 0px;
-moz-border-radius: 0px;
-ms-border-radius: 0px;
-o-border-radius: 0px;
border-radius: 2px;
-webkit-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
-moz-box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
box-shadow: 0px 0px 0px rgba(0, 0, 0, 0);
-webkit-font-smoothing: antialiased;
font-smoothing: antialiased;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
a.advert_button:hover,
.advert_button:hover,
input.advert_button[type="submit"]:hover,
input.advert_button[type="button"]:hover {
background-color: rgba(56, 58, 79, 1) !important;
border-color: #383a4f;
color: white !important;
-webkit-transition: all 200ms ease 0s;
-moz-transition: all 200ms ease 0s;
-ms-transition: all 200ms ease 0s;
-o-transition: all 200ms ease 0s;
transition: all 200ms ease 0s;
}
a.advert_button:active,
.advert_button:active,
input.advert_button[type="submit"]:active,
input.advert_button[type="button"]:active {
-webkit-box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15), 0 1px 2px rgba(0, 0, 0, .05);
-moz-box-shadow: inset 0 2px 4px rgba(0, 0, 0, .15), 0 1px 2px rgba(0, 0, 0, .05);
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0), 0 1px 2px rgba(0, 0, 0, .0);
}
.ad-col-btn-lft {
float: left;
width: 150px;
}
.ad-col-btn-rght {
float: right;
width: 150px;
}
<!-- x2880 CONTAINER -->
<a href="/collections/cufflinks/products/edward-gold">
<div style="clear: both;">
<div class="ad-col-lg hideme lazyload" style="padding-top:8px; padding-bottom:0px;">
<img src="//cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-2880.jpg?10785988739878089751" width="2880" srcset="//cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-406.jpg?10785988739878089751 406w x2, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-608.jpg?10785988739878089751 608w x2, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-800.jpg?10785988739878089751 800w, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-1024.jpg?10785988739878089751 1024w, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-1050.jpg?10785988739878089751 1050w, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-1200.jpg?10785988739878089751 1200w, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-1440.jpg?10785988739878089751 1440w, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-1920.jpg?10785988739878089751 1920w, //cdn.shopify.com/s/files/1/0786/5107/t/18/assets/mainad2-image-2880.jpg?10785988739878089751 2880w"
sizes="(max-width: 2880px) 100vw, 2880px" alt="Cufflink Edward Gold" />
<div class="ad-col-cont-lg adcol-lg-left _ms-lg">
<h2 class="advertheading" style="font-weight: normal; color: #383a4f;">Edward Gold</h2>
<p>From our latest collection of luxurious cufflinks, an absolute eye-catcher ready to complement your outfit.</p>
<div style="clear: both;" />
<a href="/collections/cufflinks/products/edward-gold" type="disable" class="advert_button ad-col-btn-lft">SHOP NOW</a>
</div>
</div>
</div>
</a>
div
element is not self-closing (aka<div />
is technically invalid and should be<div></div>
) and I personally believe that using clearing divs should not be necessary. Your position also seems very much visually guessed instead of mathematically consistent. And inline-style (as used for general things and not one-offs) are a definite no-no. \$\endgroup\$