Text with absolute position over image - html

I have an image where I need to add a tag to the right bottom corner.
When I pust it there, it's 4px below the image, no padding nor margin is there.
.postImage {
position: relative;
display: inline-block;
}
.post img.thumbnail {
width:100%;
height: 100%;
}
.commercial {
position: absolute;
bottom: 0;
right: 0;
background-color: #666;
color: #fff;
padding: 3px;
font-size: 14px;
font-weight: 100;
}
<div class="postImage">
<img class="thumbnail" src="https://dummyimage.com/600x400/f00/fff">
<span class="commercial">commercial</span>
</div>
What is the best way to fix it? I don't think
bottom: 4px;
is the right one.
Thank you

By default image tag take some extra space in bottom because it's inline element. Change it to block element to remove extra space
.thumbnail {
display: block; /*inline-block, float:left etc..*/
}
.postImage {
position: relative;
display: inline-block;
}
.post img.thumbnail {
width:100%;
height: 100%;
}
.commercial {
position: absolute;
bottom: 0;
right: 0;
background-color: #666;
color: #fff;
padding: 3px;
font-size: 14px;
font-weight: 100;
}
.thumbnail {
display: block;
}
<div class="postImage">
<img class="thumbnail" src="https://dummyimage.com/600x400/f00/fff">
<span class="commercial">commercial</span>
</div>

.postImage {
position: relative;
display: inline-block;
}
.postImage img.thumbnail {
width: 100%;
height: 100%;
display: block;
}
.commercial {
position: absolute;
bottom: 0;
right: 0;
background-color: #666;
color: #fff;
padding: 3px;
font-size: 14px;
font-weight: 100;
}
<div class="postImage">
<img class="thumbnail" src="https://dummyimage.com/600x400/f00/fff">
<span class="commercial">commercial</span>
</div>

Just add display: block; to thumbnail class.
.postImage {
position: relative;
display: inline-block;
}
.post img.thumbnail {
width:100%;
height: 100%;
}
.commercial {
position: absolute;
bottom: 0;
right: 0;
background-color: #666;
color: #fff;
padding: 3px;
font-size: 14px;
font-weight: 100;
}
.thumbnail {
display: block;
}
<div class="postImage">
<img class="thumbnail" src="https://dummyimage.com/600x400/f00/fff">
<span class="commercial">commercial</span>
</div>

That's true that img default display is inline and by changing to display:block that works, but if you don't want to change display then you can add vertical-align:bottom which aligns element to bottom line of parent div as below, and yes bottom:0 works fine as your .commercial is positioned as absolute.
.postImage {
position: relative;
display: inline-block;
}
.post img.thumbnail {
width:100%;
height: 100%;
}
.commercial {
position: absolute;
bottom: 0;
right: 0;
background-color: #666;
color: #fff;
padding: 3px;
font-size: 14px;
font-weight: 100;
}
img{
vertical-align:bottom;
}
<div class="postImage">
<img class="thumbnail" src="https://dummyimage.com/600x400/f00/fff">
<span class="commercial">commercial</span>
</div>

Related

Have pseudo border break out of parent with overflow: auto

I'm trying to create a horizontal/scrollable nav with gradient fades on each end. Setting the parent to overflow: auto almost solves my problem but hides my active link border, which I position absolute as a :before pseudo above its parent link. I was wondering if there was a way for me to keep the overflow while having my pseudo border break out of it? For the sake of this question, the gradient really doesn't matter per se but this structure needs to remain in tact.
ul {
margin: 0;
}
li {
display: inline-block;
}
.vertical-title {
height: 55px;
margin-bottom: 13px;
border-bottom: 3px solid #dceaec;
font-size: 22px;
line-height: 57px;
color: #111;
text-align: center;
text-transform: uppercase;
}
.vertical-title-wrapper {
padding: 0;
z-index: 0;
position: relative;
}
.hub-nav {
display: block;
padding: 0 15px;
width: 100%;
z-index: 1;
white-space: nowrap;
overflow: auto;
}
.hub-nav-link {
position: relative;
}
.hub-nav-link.active-path:before {
content: "";
display: block;
height: 3px;
width: 100%;
left: 0;
position: absolute;
top: -16px;
background-color: #007eff;
}
<div class="hub-wrapper">
<div class="vertical-title">
Page Title
</div>
<nav class="hub-nav">
<ul class="hub-nav-list">
<li class="hub-nav-list-item">
<a class="hub-nav-link active-path" href="">
There's supposed to be a border above me!
</a>
</li>
</ul>
</nav>
</div>
<div>
Content Below
</div>
Negative margins will do the trick:
ul {
margin: 0;
}
li {
display: inline-block;
}
.vertical-title {
height: 55px;
margin-bottom: 13px;
border-bottom: 3px solid #dceaec;
font-size: 22px;
line-height: 57px;
color: #111;
text-align: center;
text-transform: uppercase;
}
.vertical-title-wrapper {
padding: 0;
z-index: 0;
position: relative;
}
.hub-nav {
display: block;
padding: 0 15px;
width: 100%;
z-index: 1;
white-space: nowrap;
overflow: auto;
padding-top: 16px;
margin-top: -16px;
}
.hub-nav-link {
position: relative;
}
.hub-nav-link.active-path:before {
content: "";
display: block;
height: 3px;
width: 100%;
left: 0;
position: absolute;
top: -16px;
background-color: #007eff;
}
<div class="hub-wrapper">
<div class="vertical-title">
Page Title
</div>
<nav class="hub-nav">
<ul class="hub-nav-list">
<li class="hub-nav-list-item">
<a class="hub-nav-link active-path" href="">
There's supposed to be a border above me!
</a>
</li>
</ul>
</nav>
</div>
<div>
Content Below
</div>
So that you don't have to look for too long - I added these two lines into your snippet:
.hub-nav {
padding-top: 16px;
margin-top: -16px;
}

Center absolute container inside another container with CSS

Actually i have this (this screenshot is from other html where i don't need to center the image)
And i need something like this
but i cant position the play button and h3 text "inside" the image... i hope you can help me
.imgContainer {
width: 100%;
height: auto;
}
.imgContainer .botonPlay {
position: absolute;
display: block;
}
.imgContainer .botonPlay img {
margin-left: 10px;
width: 70px;
height: 65px;
}
.imgContainer h3 {
position: relative;
font-family: Roboto;
font-style: normal;
font-weight: normal;
font-size: 50px;
color: #FFFFFF;
text-shadow: 3px 1px 0px #000000;
top: 0px;
padding-left: 10px;
}
.imgContainer #imagenPeli {
display: block;
margin: auto;
}
<div class="imgContainer">
<div class="botonPlay">
<a href="ver.html">
<h3>JOKER</h3>
<img src="https://puu.sh/EwYad/148efdef71.png" alt="">
</a>
</div>
<img id="imagenPeli" src="https://puu.sh/EwFra/20b0f2b018.png" class="img-fluid" alt="...">
</div>
To position the h3 and paly button on the center of the image you can use the following css:
.imgContainer {
width: fit-content;
height: auto;
position: relative;
}
.imgContainer .botonPlay {
position: absolute;
display: flex;
top: 0;
right: 0;
bottom: 0;
left: 0;
align-items: center;
justify-content: center;
}
.imgContainer .botonPlay img {
margin: 0 auto;
width: 70px;
height: 65px;
display: block;
}
.imgContainer h3 {
position: relative;
font-family: Roboto;
font-style: normal;
font-weight: normal;
font-size: 50px;
color: #FFFFFF;
text-shadow: 3px 1px 0px #000000;
top: 0px;
padding-left: 10px;
}
.imgContainer #imagenPeli {
display: block;
margin: auto;
width: 100%;
}
<div class="imgContainer">
<div class="botonPlay">
<a href="ver.html">
<h3>JOKER</h3>
<img src="https://puu.sh/EwYad/148efdef71.png" alt="">
</a>
</div>
<img id="imagenPeli" src="https://puu.sh/EwFra/20b0f2b018.png" class="img-fluid" alt="...">
</div>

Cannot see the full image with a fixed position on safari

I have created a navbar using HTML and CSS. It works perfectly on IE, Opera, and Chrome.
However, on Safari the logo seems to be cut off. All I did was to add the position fixed to the logo to make the logo stick to the top of the page when the user scrolls down the page.
My HTML:
<div id="nav">
<div id="top-bar">
<div class="container">
<div class="left-right-nav">
<div class="left-nav-2">
<div>
<span></span>
<span><i class="fab fa-facebook"></i> <i class="fab fa-twitter"></i> <i class="fab fa-instagram"></i></span>
<span style="visibility: hidden;">ffff</span>
</div>
</div>
<div class="right-nav">
<div>
<span>01283 575 671</span>
<span>Join Now</span>
</div>
</div>
</div>
<div class="center-container">
<span style="padding:0;"><img src="https://via.placeholder.com/250x115" alt="" width="100%"></span>
</div>
</div>
</div>
<div class="nav-bg">
<div class="container">
<div class="left-right-nav">
<div class="left-nav">
<div>
<span>Facilties</span>
<span>Timetable</span>
<span>Blog</span>
</div>
</div>
<div class="right-nav">
<div>
<span>The Team</span>
<span>Events</span>
<span>Contact Us</span>
</div>
</div>
</div>
<div class="center-nav">
</div>
</div>
</div>
</div>
My CSS:
body{
margin:0;
}
#nav {
z-index: 999;
}
.left-container,
.center-container,
.right-container {
position: absolute;
display: inline-block;
margin: 0;
padding: 0;
width: calc(50% - 125px);
}
.left-container {
left: 0;
height: 50px;
overflow: hidden;
}
.left-container span {
margin: auto;
left: 0;
right: 0;
position: absolute;
}
.center-container {
width: 250px;
height: 115px;
z-index: 2;
left: 0;
right: 0;
margin: auto;
}
.right-container {
right: 0;
height: 50px;
overflow: hidden;
}
.right-container span:last-child {
background: #081F2D;
width: 40%;
float: right;
}
.right-container span:last-child a {
color: #FFDE00;
}
.left-right-container {
background: #FFDE00;
height: inherit;
}
.left-container span,
.right-container span {
padding: 15px 15px;
font-weight: 500;
text-transform: uppercase;
width: 59%;
display: inline-block;
}
.left-container span a,
.right-container span a {
display: block;
color: #081F2D;
text-decoration: none;
text-align: center;
font-size: 17px;
}
#top-bar {
float: left;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 0px;
overflow: hidden;
width: 100%;
min-width: 650px;
min-height: 50px;
position: fixed;
z-index: 999;
}
.nav-bg {
width: 100%;
position: absolute;
top: 50px;
height: 50px;
z-index: 2;
margin-top: -1px;
}
.left-right-nav {
background-color: #EEEEEE;
height: inherit;
}
.left-nav,
.left-nav-2,
.center-nav,
.right-nav {
position: fixed;
display: inline-block;
width: calc(50% - 125px);
}
.left-nav,
.left-nav-2{
left: 0;
}
.center-nav {
width: 250px;
height: 50px;
z-index: 1;
left: 0;
right: 0;
margin: auto;
}
.right-nav {
right: 0;
}
/*.left-nav:after, .right-nav:after {
content: '';
display: inline-block;
width: 100%;
}*/
.left-nav div,
.left-nav-2 div,
.left-nav-2 div,
.right-nav div {
margin: auto;
left: 0;
right: 0;
position: absolute;
background-color: #EEEEEE;
text-align: right;
margin-left: -20px;
}
.left-nav-2 div{
background-color: #FFDE00;
}
.left-nav div span {}
.right-nav div span {
float: left;
}
.left-nav div span,
.left-nav-2 div span,
.right-nav div span {
display: inline-block;
}
.left-nav span a,
.left-nav-2 span a,
.right-nav span a {
padding: 15px 40px;
display: block;
font-size: 1rem;
text-align: center;
color: #081F2D;
text-transform: uppercase;
font-weight: 600;
text-decoration: none;
background-color: #EEEEEE;
}
}
The codepen to my problem is https://codepen.io/anon/pen/xymdmP
Try adding position: fixed; and -webkit-transform: translate3d(0, 0, 0); instead of on image tag style.
https://codepen.io/anon/pen/MPZPPy
Thanks

Overlay on Responsive Image for horizontal Image

I am trying to create an overlay for responsive images in a horizontal gallery.
The overlay div in the li has position and a large z-index value but still displays on background of the image.
When I try to do absolute for an image with higher z-index the horizontal scrolling for image fails.
See the demo: Jsfiddle
html,
body {
min-height: 100%;
height: 100%;
}
body {
width: 100%;
margin: 0;
padding: 0;
}
#thumbsList {
height: 76%;
white-space: nowrap;
margin: 0;
padding: 0;
line-height: 0px;
top: 13%;
left: 80px;
list-style-type: none;
top: 13%;
position: absolute;
}
#thumbsList li {
display: inline;
position: relative;
}
#thumbsList li img {
max-width: 100%;
height: 100%;
transition: all 0.8s ease;
}
.Absolute-Center {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.backStrip {
background-color: #2d2d2d;
border-bottom: 1px solid #1a1a1a;
height: 35px;
position: relative;
z-index: 22;
position: fixed;
width: 253px;
top: 43px;
height: 79px;
left: 85px;
}
#infoText {
color: white;
font-style: italic;
padding-top: 10px;
float: right;
margin-right: 10px;
font-family: sans-serif;
font-size: 12px;
}
#mainContainer {
height: 100%;
width: 100%;
position: fixed;
z-index: 1;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 8px solid #2D2D2D;
margin: 0px;
overflow-x: auto;
}
#thumbsButtons {
list-style: none;
position: fixed;
bottom: 6%;
left: 46%;
z-index: 22;
}
#counterContainer {
position: fixed;
bottom: 5%;
left: 50%;
right: 50%;
font-family: verdana;
font-weight: bold;
width: 100px;
}
#thumbsButtons li {
float: left;
margin-left: 11px;
font-size: 16px;
font-family: verdana;
}
#thumbsButtons li:hover {
cursor: pointer;
}
#nextArrow {
position: fixed;
right: 10px;
top: 43%;
z-index: 13333;
font-size: 100px;
color: white;
font-family: helvetica;
cursor: pointer;
}
#sidelogo {
position: absolute;
z-index: 10;
top: 35%;
left: 0%;
width: 67px;
height: 258px;
background-color: #2D2D2D;
}
.headerInfo {
position: absolute;
bottom: 22px;
color: white;
z-index: 333;
font-family: verdana;
font-size: 17px;
text-align: center;
}
.thumbOverlay {
position: absolute;
z-index: 13111133;
background-color: black;
color: white;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
display: inline;
}
<div id="mainContainer">
<div class="backStrip"> <span id="infoText">Written By Banmeet Singh</span>
</div>
<ul id="thumbsButtons"></ul> <span id="nextArrow">></span>
<span id="sidelogo">Thinking Forward</span>
<ul id="thumbsList">
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" /> <span class="headerInfo">Josh Kloss</span>
</li>
<li>
<div class="thumbOverlay"><span>adasd</span>
</div>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
</ul>
<div id="counterContainer">3 of 10</div>
Check the Second Image. I have added the overlay to that.
#thumbsList li {
display: inline-block;
position: relative;
}
are you expecting this kind of result?
see jsFiddle
Check this out: https://jsfiddle.net/r6hho2sL/11/
here I made some modifications to your code:
1. I used JQuery to adjust the width of the overlay element on window re-size event so that it would keep its responsive behavior
$( window ).resize(function() {
$( ".thumbOverlay" ).width($(".forward").width());
});
$( ".thumbOverlay" ).width($(".forward").width());
I used (divs and spans) instead of list (ul and li)
I modified the css classes
.thumbOverlay {
top: 0;
position: absolute;
z-index: 13111133;
background-color: black;
color: white;
height: 100%;
display: inline;
}
#thumbsList span {
display: inline;
margin-left: -4px;
}
Marc Andre, your fiddle(s) code is, unfortunately, rather leaky and inconsistent. So, instead of patching and rearranging it, I took the liberty of starting from scratch staying as close to your original idea as possible.
For a quick look, check my Pen on CODEPEN Responsive filmstrip and thumblist
Where did you go wrong?
First of all, I don't intend to pick on you, I am just being honest:
You didn't use 'position' correctly on your elements, which (probably) resulted in a confusing (hair-pulling, I guess) onscreen output.
Two general rules:
1) parent-element => position: relative, child-element => position: absolute.
Both can have any kind of width/height (%, px), but the child values are relative to the parent-element.
2) child-element => position: fixed. Width/height/position are relative to the browser window, ALWAYS.
You mixed the two rules and got yourself running in circles. To break free you should do:
/* Generally accepted (and working) init of HTML and BODY */
html, body { width: 100%; height: 100%; margin: 0; padding: 0 }
body { max-width: 100%; margin: 0 auto }
/* margin: 0 auto will center BODY onscreen if max-width < 100% */
#thumbsList { position: absolute /* relative to BODY!!! which is a parent */ }
#thumbsList li { position: relative /* while a child of UL, it is a parent of IMG */ }
#thumbsList li img { position: absolute /* child of LI absolute coords relative to LI */ }
No further 'position'ing should be needed for #thumbslist (only sizing, styling and such).
Again unfortunately, because of the number of (logic) errors, your CSS requires to be redesigned (IMHO that is).
UPDATE
As you may have seen by now, the code works on Codepen and standalone in the latest IE11, FF and CH (all W7, I still need to check mobile).
What I essentially created is a strip of stacked flexbox layout layers. Once you master the flexbox techniques, you wil see that it has lots of advantages over regular (inline-)block techniques. Drawbacks too, I will point them out where applicable.
To easily understand my (very down to earth) flexbox workflow I always ask what basic layout is needed:
a column of rows or a row of columns
wrapping or not
justification (often justify-content: space-between, you may want to read into this)
Nesting and trickery will come later...
Dissecting your requirements: you actually need a regular webpage, but instead of nicely placed blocks, you need them stacked, hence the need for layers
Why is this happening?
This is not an issue with z-index as .thumbOverlay is stacked on top of the image. The issue is that .thumbOverlay has a percentage height which means it will take up the full height of its container. In this case the container is a li which has been setup as display: inline; so its height will be as high as its line box.
What can you do?
For your overlay to work you either need height: 100%; to calculate the correct height.
Method 1: Make the list item inline-block
If you make the li display: inline-block; then you will be able to set its height.
Change display: inline; to display: inline-block; on #thumbsList li
Add height: 100%; to #thumbsList li to make the li the height of the ul
Change max-width: 100%; to max-width: calc(100vw - 96px); on #thumbsList li img. This will ensure that the img takes up the full width of the viewport, minus the borders and positioning applied to the #mainContainer and #thumbsList
html, body {
min-height: 100%;
height: 100%;
}
body {
width: 100%;
margin: 0;
padding: 0;
}
#thumbsList {
height: 76%;
white-space: nowrap;
margin: 0;
padding: 0;
line-height: 0px;
top: 13%;
left: 80px;
list-style-type: none;
top: 13%;
position: absolute;
}
#thumbsList li {
/*display: inline;REMOVE THIS*/
display: inline-block; /*ADD THIS*/
height: 100%; /*ADD THIS*/
position: relative;
}
#thumbsList li img {
/*max-width: 100%; REMOVE THIS*/
max-width: calc(100vw - 96px); /*ADD THIS*/
height: 100%;
transition: all 0.8s ease;
}
.Absolute-Center {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.backStrip {
background-color: #2d2d2d;
border-bottom: 1px solid #1a1a1a;
height: 35px;
position: relative;
z-index: 22;
position: fixed;
width: 253px;
top: 43px;
height: 79px;
left: 85px;
}
#infoText {
color: white;
font-style: italic;
padding-top: 10px;
float: right;
margin-right: 10px;
font-family: sans-serif;
font-size: 12px;
}
#mainContainer {
height: 100%;
width: 100%;
position: fixed;
z-index: 1;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 8px solid #2D2D2D;
margin: 0px;
overflow-x: auto;
}
#thumbsButtons {
list-style: none;
position: fixed;
bottom: 6%;
left: 46%;
z-index: 22;
}
#counterContainer {
position: fixed;
bottom: 5%;
left: 50%;
right: 50%;
font-family: verdana;
font-weight: bold;
width: 100px;
}
#thumbsButtons li {
float: left;
margin-left: 11px;
font-size: 16px;
font-family: verdana;
}
#thumbsButtons li:hover {
cursor: pointer;
}
#nextArrow {
position: fixed;
right: 10px;
top: 43%;
z-index: 13333;
font-size: 100px;
color: white;
font-family: helvetica;
cursor: pointer;
}
#sidelogo {
position: absolute;
z-index: 10;
top: 35%;
left: 0%;
width: 67px;
height: 258px;
background-color: #2D2D2D;
}
.headerInfo {
position: absolute;
bottom: 22px;
color: white;
z-index: 333;
font-family: verdana;
font-size: 17px;
text-align: center;
}
.thumbOverlay {
position: absolute;
z-index: 13111133;
background-color: black;
color: white;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
/*display: inline; REMOVE THIS*/
}
<div id="mainContainer">
<div class="backStrip">
<span id="infoText">Written By Banmeet Singh</span>
</div>
<ul id="thumbsButtons"></ul> <span id="nextArrow">></span>
<span id="sidelogo">Thinking Forward</span>
<ul id="thumbsList">
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" /> <span class="headerInfo">Josh Kloss</span>
</li>
<li>
<div class="thumbOverlay"><span>adasd</span> </div>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
</ul>
<div id="counterContainer">3 of 10</div>
</div>
https://jsfiddle.net/vhqg2zg3/2/
Method 2: Make the overlay relative to the list
If you make .thumbOverlay position relative to the ul you will be able to get the height from the ul instead.
Remove position: relative; from #thumbsList li. This will stop .thumbOverlay from being relative to it
Remove left: 0px; from .thumbOverlay. This will ensure that its left position is kept at where it is initially drawn
html, body {
min-height: 100%;
height: 100%;
}
body {
width: 100%;
margin: 0;
padding: 0;
}
#thumbsList {
height: 76%;
white-space: nowrap;
margin: 0;
padding: 0;
line-height: 0px;
top: 13%;
left: 80px;
list-style-type: none;
top: 13%;
position: absolute;
}
#thumbsList li {
display: inline;
/*position: relative; REMOVE THIS*/
}
#thumbsList li img {
max-width: 100%;
height: 100%;
transition: all 0.8s ease;
}
.Absolute-Center {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.backStrip {
background-color: #2d2d2d;
border-bottom: 1px solid #1a1a1a;
height: 35px;
position: relative;
z-index: 22;
position: fixed;
width: 253px;
top: 43px;
height: 79px;
left: 85px;
}
#infoText {
color: white;
font-style: italic;
padding-top: 10px;
float: right;
margin-right: 10px;
font-family: sans-serif;
font-size: 12px;
}
#mainContainer {
height: 100%;
width: 100%;
position: fixed;
z-index: 1;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 8px solid #2D2D2D;
margin: 0px;
overflow-x: auto;
}
#thumbsButtons {
list-style: none;
position: fixed;
bottom: 6%;
left: 46%;
z-index: 22;
}
#counterContainer {
position: fixed;
bottom: 5%;
left: 50%;
right: 50%;
font-family: verdana;
font-weight: bold;
width: 100px;
}
#thumbsButtons li {
float: left;
margin-left: 11px;
font-size: 16px;
font-family: verdana;
}
#thumbsButtons li:hover {
cursor: pointer;
}
#nextArrow {
position: fixed;
right: 10px;
top: 43%;
z-index: 13333;
font-size: 100px;
color: white;
font-family: helvetica;
cursor: pointer;
}
#sidelogo {
position: absolute;
z-index: 10;
top: 35%;
left: 0%;
width: 67px;
height: 258px;
background-color: #2D2D2D;
}
.headerInfo {
position: absolute;
bottom: 22px;
color: white;
z-index: 333;
font-family: verdana;
font-size: 17px;
text-align: center;
}
.thumbOverlay {
position: absolute;
z-index: 13111133;
background-color: black;
color: white;
height: 100%;
width: 100%;
/*left: 0px; REMOVE THIS*/
top: 0px;
display: inline;
}
<div id="mainContainer">
<div class="backStrip">
<span id="infoText">Written By Banmeet Singh</span>
</div>
<ul id="thumbsButtons"></ul> <span id="nextArrow">></span>
<span id="sidelogo">Thinking Forward</span>
<ul id="thumbsList">
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" /> <span class="headerInfo">Josh Kloss</span>
</li>
<li>
<div class="thumbOverlay"><span>adasd</span> </div>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
</ul>
<div id="counterContainer">3 of 10</div>
</div>
https://jsfiddle.net/pmuqvLpm/
It's worth noting that the way you are currently scaling your images will lead to distortion as they are not going to keep their aspect ratio. This is because the height of the image is remaining static while the width scales. It may be worth doing something like this instead:
html, body {
min-height: 100%;
height: 100%;
}
body {
width: 100%;
margin: 0;
padding: 0;
}
#thumbsList {
height: 76%;
white-space: nowrap;
margin: 0;
padding: 0;
line-height: 0px;
top: 13%;
left: 80px;
list-style-type: none;
top: 13%;
position: absolute;
}
#thumbsList li {
/*display: inline;REMOVE THIS*/
display: inline-block; /*ADD THIS*/
vertical-align: middle; /*ADD THIS*/
position: relative;
}
#thumbsList li img {
width: calc(100vw - 96px); /*ADD THIS*/
transition: all 0.8s ease;
}
.Absolute-Center {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
.backStrip {
background-color: #2d2d2d;
border-bottom: 1px solid #1a1a1a;
height: 35px;
position: relative;
z-index: 22;
position: fixed;
width: 253px;
top: 43px;
height: 79px;
left: 85px;
}
#infoText {
color: white;
font-style: italic;
padding-top: 10px;
float: right;
margin-right: 10px;
font-family: sans-serif;
font-size: 12px;
}
#mainContainer {
height: 100%;
width: 100%;
position: fixed;
z-index: 1;
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
border: 8px solid #2D2D2D;
margin: 0px;
overflow-x: auto;
}
#thumbsButtons {
list-style: none;
position: fixed;
bottom: 6%;
left: 46%;
z-index: 22;
}
#counterContainer {
position: fixed;
bottom: 5%;
left: 50%;
right: 50%;
font-family: verdana;
font-weight: bold;
width: 100px;
}
#thumbsButtons li {
float: left;
margin-left: 11px;
font-size: 16px;
font-family: verdana;
}
#thumbsButtons li:hover {
cursor: pointer;
}
#nextArrow {
position: fixed;
right: 10px;
top: 43%;
z-index: 13333;
font-size: 100px;
color: white;
font-family: helvetica;
cursor: pointer;
}
#sidelogo {
position: absolute;
z-index: 10;
top: 35%;
left: 0%;
width: 67px;
height: 258px;
background-color: #2D2D2D;
}
.headerInfo {
position: absolute;
bottom: 22px;
color: white;
z-index: 333;
font-family: verdana;
font-size: 17px;
text-align: center;
}
.thumbOverlay {
position: absolute;
z-index: 13111133;
background-color: black;
color: white;
height: 100%;
width: 100%;
left: 0px;
top: 0px;
/*display: inline; REMOVE THIS*/
}
#thumbsList:after {
content: "";
height: 100%;
display: inline-block;
vertical-align: middle;
}
<div id="mainContainer">
<div class="backStrip">
<span id="infoText">Written By Banmeet Singh</span>
</div>
<ul id="thumbsButtons"></ul> <span id="nextArrow">></span>
<span id="sidelogo">Thinking Forward</span>
<ul id="thumbsList">
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" /> <span class="headerInfo">Josh Kloss</span>
</li>
<li>
<div class="thumbOverlay"><span>adasd</span> </div>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/350x150" alt="Alternate Text" />
</li>
<li>
<img class="forward" src="http://placehold.it/200x100" alt="Alternate Text" />
</li>
</ul>
<div id="counterContainer">3 of 10</div>
</div>
https://jsfiddle.net/vwxznmhy/
Add this.
#thumbsList li {
display: inline-block;
position: relative;
height: 100%;
}
Issue -
since li is made display:inline, it is not taking up 100% height of your ul i.e. #thumbsList.
Solution-
After making your li display:inline-block and adding height:100%, li element took entire height of ul and thumbOverlay div which is a child elemt of li also took up 100% height.

CSS: Hover effect over image with width: auto

I'm trying to make a caption appear whenever I hover on the image. I want the height of the image to be set to 200px, but the width to be auto. How can I make the span with the caption also correspond to the image width? Thanks!
HTML:
<div class="projects">
<a name="folder"></a>
<h1 class="heading">Projects</h1>
<p class="classProjectsInfo">Recent class projects</p>
<div class="classProjects">
<ul class="img-list">
<li>
<img src="checkers_cover.JPG">
<span class="description2"><span>Checkers61B</span></span>
</li>
<li>
<img src="cover_ngram.JPG">
<span class="description2"><span>NGramMap</span></span>
</li>
<li>
<img src="gitlet_cover.JPG">
<span class="description2"><span>Gitlet</span></span>
</li>
</ul>
</div>
</div>
CSS:
.classProjects {
text-align: center;
margin: 0;
padding: 0;
list-style-type: none;
}
.classProjects li {
display: inline-block;
padding: 5px;
margin: 10px;
position: relative;
height: 250px;
width: auto;
}
.classProjects img {
height: 250px;
width: auto;
}
ul.img-list {
list-style-type: none;
margin: 0;
padding: 0;
text-align: center;
}
ul.img-list li {
display: inline-block;
height: 250px;
position: relative;
width: auto;
}
span.description2 {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 250px;
left: 0;
position: absolute;
top: 0;
width: auto;
}
span.description2 span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
span.description2 {
background: rgba(0,0,0,0.5);
color: white;
cursor: pointer;
display: table;
height: 250px;
left: 0;
position: absolute;
top: 0;
width: auto;
opacity: 0;
}
ul.img-list li:hover span.description2 {
opacity: 1;
}