I have created this layout for my blog posts and each post automatically gets posted there. I am quite happy with the setup I have, but I cannot for the life of me get the text centered (vertically) on the image (it already horizontally centered). Just wondering how others would approach this.
I have completely laid out the HTML and CSS here in a codepen. If you are interested in tweaking the code, I would appreciate if you based it off of the current css classes in the codepen. :)
Thanks in advance for your help and recommendations!
HTML:
<div id="blog-posts">
<div class="blog-post">
<a href="http://www.ericshio.com/2016/08/07/test-2/">
<img width="5472" height="3648" src="http://www.ericshio.com/wp-content/uploads/2016/08/IMG_0303.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="IMG_0303" srcset="http://www.ericshio.com/wp-content/uploads/2016/08/IMG_0303.png 5472w, http://www.ericshio.com/wp-content/uploads/2016/08/IMG_0303-300x200.png 300w, http://www.ericshio.com/wp-content/uploads/2016/08/IMG_0303-768x512.png 768w, http://www.ericshio.com/wp-content/uploads/2016/08/IMG_0303-1024x683.png 1024w" sizes="(max-width: 5472px) 100vw, 5472px" scale="0">
<h3>Test 2</h3>
</a>
</div>
<div class="blog-post">
<a href="http://www.ericshio.com/2016/08/07/hey-johnson/">
<img width="5472" height="3648" src="http://www.ericshio.com/wp-content/uploads/2016/08/macbook.png" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="macbook" srcset="http://www.ericshio.com/wp-content/uploads/2016/08/macbook.png 5472w, http://www.ericshio.com/wp-content/uploads/2016/08/macbook-300x200.png 300w, http://www.ericshio.com/wp-content/uploads/2016/08/macbook-768x512.png 768w, http://www.ericshio.com/wp-content/uploads/2016/08/macbook-1024x683.png 1024w" sizes="(max-width: 5472px) 100vw, 5472px">
<h3>Hey Johnson</h3>
</a>
</div>
</div>
CSS:
#blog-posts {
text-align: center;
display: inline-block;
max-width: 100%;
}
.blog-post {
width: 40%;
height: auto;
display: inline-block;
position: relative;
margin: 0.2em;
overflow: hidden;
}
.blog-post h3 {
font: 1em Cabin Sketch;
color: white;
width: 100%;
height: 100%;
line-height: 100%;
text-transform: uppercase;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 0;
padding: 0;
font-size: 2em;
background-color: rgba(0,0,0,0.4);
opacity: 0;
-webkit-transition: opacity 0.6s;
-moz-transition: opacity 0.6s;
transition: opacity 0.6s;
vertical-align: middle !important;
}
.attachment-post-thumbnail {
position: relative;
width: 100%;
display: inline-block;
height: auto;
}
.blog-post:hover h3,
.blog-post h3:hover,
.blog-post .attachment-post-thumbnail:hover {
opacity: 1;
}
.blog-post:hover .attachment-post-thumbnail {
-webkit-filter: blur(1px);
opacity: 1;
}
I set padding-top to 30%. Check out the codepen:
http://codepen.io/anon/pen/mEQVZy
Related
I created a curvy shape at the bottom of this image on this bootstrap card. I'm using bootstrap 5.
This works flawless on a resolution of 1400px and higher. However, on smaller devices the shape seems to disappear (causing the image to be just rectangular) and whatever I try, nothing seems to make a difference.
This is my HTML
<div class="col-lg-3 col-sm-6">
<div class="card h-100">
<div class="card-img">
<img src="..." class="card-img-top img-fluid" alt="">
</div>
<div class="card-body">
<h4 class="card-title">Heroine's Quest: ...</h4>
<h5>Winner of 11 AGS Awards</h5>
<p class="card-text">Heroine's Quest is an adventure / RPG hybrid. Like in many adventure
games, you have a world to save, and must use your wit, guile and inven...</p>
</div>
<div class="card-footer">
<a href="game-details.php" class="btn btn-ags">Learn more <span class="d-none d-sm-inline">
<i class="fas fa-arrow-right"></i></span> </a>
</div>
</div>
</div>
</div>
And this is my CSS:
.card {
box-shadow: 0 0 30px rgba(68, 68, 68, 0.2);
transition: .3s;
background-color: #fff;
margin-top: 10px;
}
#media (min-width: 481px) {
.card:hover {
transform: scale(1.05);
transition: .3s;
}
}
.card .card-img {
position: relative;
overflow: hidden;
height: 200px;
}
.card .card-img img {
max-height: 199px;
width: 100%;
}
.card .card-img:after {
background: url(../img/home-game-highlights-shape.svg) no-repeat center bottom;
background-size: contain;
bottom: 0;
content: "";
height: 100%;
left: 0;
position: absolute;
width: 100%;
z-index: 999;
}
.card .card-footer {
background-color: #fff;
border-top: none;
text-align: center;
}
This is the .svg used:
https://www.rwdb.info/home-game-highlights-shape.svg
And this is the code in JSFiddle:
https://jsfiddle.net/f2Lengk6/
I've been trying for hours and of course just after I posted I found the resolution:
I updated this:
.card .card-img img {
max-height: 199px;
width: 100%;
}
to this:
.card .card-img img {
height: 199px;
width: 100%;
}
I would like to add a link to an image that has an overlay applied to it. When users hover over the image they get an opaque overlay and text appear. This works great, however I also need users to be able to click that image and taken to a link.
I have pasted my code below - the overlay works but the link portion does not. I believe it's because the overlay is interfering. I tried changing the placement of the link but was unable to do so. I am able to make the '+' be the link, but ideally the entire image should link.
Any thoughts?
JSFiddle
.roomphoto:hover .img__description { transform: translateY(0); }
.roomphoto .img__description_layer { top: 30px; }
.roomphoto:hover .img__description_layer { visibility: visible; opacity: 1; }
.img__description_layer {
position: absolute;
bottom: 0;
left: 0;
right: 0;
color: #cdcbca;
visibility: hidden;
opacity: 0;
display: flex;
align-items: center;
justify-content: center;
transition: opacity .2s, visibility .2s;
}
.roomphoto {
height: 166px;
}
.img__description {
transition: .2s;
transform: translateY(1em);
z-index: 999;
}
.overlay {
position: relative;
}
.overlay:after {
position: absolute;
content:"";
top:0;
left:0;
width:100%;
height:100%;
opacity:0;
}
.overlay:hover:after {
opacity: .8;
}
.blue:after {
background-color: #1a3761;
}
.img__description a {
color: #fff;
}
.roomselect {
clear: both;
float: none;
width: 100%;
max-width: 1000px;
margin: 0px auto;
padding-top: 20px;
}
.roomselect img {
width: 100%;
margin-bottom: -10px;
}
.room3 {
width: 32%;
text-align: left;
float:left;
}
<div class="roomselect"><div class="room3">
<div class="roomphoto overlay blue">
<a href="http://www.google.com">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
</a>
<div class="img__description_layer">
<p class="img__description">
<span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span>
</p>
</div>
</div>
</div>
You need to rearrange your html in such a way that when you click on image, you are actually clicking on the anchor tag. I have made some changes to your html, let me know if these work. You might have to increase roomphoto height.
<div class="roomselect">
<div class="room3">
<a href="http://www.google.com">
<div class="roomphoto overlay blue">
<img src="https://cdn.mos.cms.futurecdn.net/J9KeYkEZf4HHD5LRGf799N-650-80.jpg" alt="Image Text" />
<div class="img__description_layer">
<p class="img__description"><span style="border-radius: 50%; width: 30px; height: 30px; padding: 0px 14px; border: 1px solid #fff; text-align: center; font-size: 36px;">+</span></p>
</div>
</div>
</a>
</div>
</div>
I've got a problem with my text when the browser is shrunk or on a mobile device. Here is a screenshot to help explain. On a larger screen the 'matched' text is on the same line as 'what is' so there is no problem. Below is the code I'm using at the minute. I would like the gap to be the same as the one below 'matched'. Thanks in advance.
HTML
<div class="outer-wrapper">
<img class="aligncenter wp-image-1015"
src="https://www.thesurebettor.com/wp-content/uploads/2017/05/what-is-
matched-betting-1.jpg" alt="" width="750" height="431" />
<div class="text-wrapper"><p>What is matched</p><p>betting?</P>
</div>
</div>
CSS
.aligncenter {
display: block;
margin: auto;
max-width: 100%;
height: auto;
}
.outer-wrapper {
position: relative;
}
.text-wrapper {
position: absolute;
left: 50%;
top: 35px;
transform: translateX(-90%);
color: white;
font-size: 52px;
font-weight: bold;
}
You are using two paragraphs for the text, but semantically it is one paragraph:
<p>What is matched betting?</p>
This is also the root of your problem - you can solve it using two paragraphs by ensuring the line height and the margins/padding match - but using a single paragraph would be better.
Just add line-height: 1 on .text-wrapper div.
.aligncenter {
display: block;
margin: auto;
max-width: 100%;
height: auto;
}
.outer-wrapper {
position: relative;
}
.text-wrapper {
position: absolute;
left: 50%;
top: 35px;
transform: translateX(-90%);
color: white;
font-size: 52px;
font-weight: bold;
line-height:1;
}
<div class="outer-wrapper">
<img class="aligncenter wp-image-1015"
src="https://www.thesurebettor.com/wp-content/uploads/2017/05/what-is-
matched-betting-1.jpg" alt="" width="750" height="431" />
<div class="text-wrapper"><p>What is matched</p><p>betting?</p></div>
</div>
You written wrong html. please make it correct.
.aligncenter {
display: block;
margin: auto;
max-width: 100%;
height: auto;
}
.outer-wrapper {
position: relative;
}
.text-wrapper {
position: absolute;
left: 50%;
top: 35px;
transform: translateX(-90%);
color: white;
font-size: 52px;
font-weight: bold;
}
<div class="outer-wrapper">
<img class="aligncenter wp-image-1015"
src="https://www.thesurebettor.com/wp-content/uploads/2017/05/what-is-
matched-betting-1.jpg" alt="" width="750" height="431" />
<div class="text-wrapper"><p>What is matched</p><p>betting?</p></div>
</div>
Click here for the Snapshot
Your issue is not reproducible from my end, check the above snapshot.
It may be caused because of some other styling in your css. Anyhow
please make text responsive.
Please include font-size: 100% for the body and use media query to target the screen where the text is overlapping
eg.,
#media only screen and (min-width: 320px) and (max-width: 535px){
//give font-size in percentage for text-wrapper p and if required include line-height as well
}
I'm managing the website of my company which is based on Wordpress and I try to figure out how to change my contact page.
I've made a codepen of what I want to do : http://codepen.io/EzhnoFR/pen/PNmdxm
html :
<img class="top" src="http://www.alabama-pub.com/wp-content/uploads/2016/03/Isa.png" />
<span>Hover</span>
</div>
<div id="cf">
<img class="bottom" src="http://www.alabama-pub.com/wp-content/uploads/2016/03/christine-chute.png" />
<img class="top" src="http://www.alabama-pub.com/wp-content/uploads/2016/03/christine-1.png" />
<span> Hover </span>
</div>
<div id="cf">
<img class="bottom" src="http://www.alabama-pub.com/wp-content/uploads/2016/03/cecile-chute.png" />
<img class="top" src="http://www.alabama-pub.com/wp-content/uploads/2016/03/cecile.png" />
<span> Hover </span>
</div>
</div>
css :
#cf img.top {
-webkit-filter: grayscale(80%);
filter: grayscale(80%);
}
#cf img.top:hover {
opacity:0;
}
span{
position: absolute;
bottom: -150px;
left: 0;
z-index: -1;
display: block;
width: 225px;
margin: 0;
padding: 0;
color: black;
font-size: 25px;
text-decoration: none;
text-align: center;
-webkit-transition: .7s ease-in-out;
transition: .7s ease-in-out;
opacity: 0;
}
#cf img.top:hover ~ span{
opacity: 1;
}
/*-----------------------------------------------------*/
.column {
margin: 15px 15px 0;
padding: 0;
}
.column:last-child {
padding-bottom: 90px;
}
.column::after {
content: '';
clear: both;
display: block;
}
.column div {
position: relative;
float: left;
width: 300px;
height: 200px;
margin: 0 0 0 50px;
padding: 0;
}
.column div:first-child {
margin-left: 0;
}
However, when I add this html to my page and the css in my wordpress custom css, it all mess up as you can see : http://www.alabama-pub.com/contact-new-test/
I've tried a lot of things but I can't get to fix it, does anyone has any idea ?
You have extra < br > under image tag which is causing the issue of height changes on hover.
According to other issue please remove z-index from span tag and you are done :)
see
I have a small bug that is driving me nuts. I have three social media icons that I want to display in an inline-block fashion. My code is correct, as far as I can see. I even made a snippet and it looks to be correct. I looked in my dev tools and do not see anything causing this issue. It is happening on my site in a viewport of 640px or less. This is making it hard to see what is wrong in the dev tools because of the small screen.
Does anyone see anything standing out? Please view the page in a viewport of 640px or less.
Click here to see live
.nav-panel-container {
position: fixed;
width: 70%;
height: 100%;
top: 0;
bottom: 0;
background: #F0F0F0;
z-index: 1;
-webkit-transition-property: -webkit-transform;
-moz-transition-property: -moz-transform;
transition-property: transform;
-webkit-transition-duration: 0.7s;
-moz-transition-duration: 0.7s;
transition-duration: 0.7s;
-webkit-transition-delay: 0.3s;
-moz-transition-delay: 0.3s;
transition-delay: 0.3s;
}
.nav-panel-content {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 50px 0 0 0;
overflow: auto;
/* smooth scrolling on touch devices */
-webkit-overflow-scrolling: touch;
}
#nav-social-container {
bottom: 8%;
position: absolute;
text-align: center;
display: block;
width: 80%;
margin-left: 10%;
}
#nav-social-title {
font-size: .8em;
}
#nav-social-icons {
display: inline-block;
margin-top: 15px;
}
.nav-social-icon {
padding: 0 15px;
width: 100%;
}
.nav-social-icon:first-child {
padding-left: 0;
}
.nav-social-icon:last-child {
padding-right: 0;
}
<div class="nav-panel-container">
<div class="nav-panel-content">
<div id="nav-social-container">
<div id="nav-social-title">DON'T BE SHY, LET'S GET SOCIAL.</div>
<div id="nav-social-icons"><span class="nav-social-icon"><img src="http://optimumwebdesigns.com/icons/facebookBlack.png" alt="facebook" height="30px" width="30px"></span><span class="nav-social-icon"><img src="http://optimumwebdesigns.com/icons/twitterBlack.png" alt="twitter" height="30px" width="30px"></span>
<span
class="nav-social-icon">
<a href="http://linkedin.com" target="_blank">
<img src="http://optimumwebdesigns.com/icons/linkedInBlack.png" alt="linkedIn" height="30px" width="30px">
</a>
</span>
</div>
</div>
You're using <span> tags - these are display:inline - change them to block or inline-block.