issue with css positioning in wordpress columns - html

I am having an issue with positioning a caption on top of a picture. The pictures are in a column, there are 4 columns. The first 3 columns seem to work fine but then when it comes to the last column, it does not look right at all and I feel like it may have to do with wordpress css? I have tried to add css to the last column which positions it correctly but then the width is not right... I am so confused. This may be such a simple fix but I can't seem to figure it out
Here is the link to the website
http://aminkhalil.com
Here is my html code
[fourcol_one]
<a href="#" class="caption">
<img class="hover" alt="Services" src="http://growinggood.com/wp-content/uploads/2014/02/billboard-slider-images.jpg" />
<span class="caption">Services</span></a>
[/fourcol_one]
[fourcol_one]
<a href="#" class="caption">
<img class="hover" alt="Keep Healthy" src="http://growinggood.com/wp-content/uploads/2014/02/billboard-slider-images.jpg" />
<span class="caption">Keep Healthy</span></a>
[/fourcol_one]
[fourcol_one]
<a href="#" class="caption">
<img class="hover" alt="Meet The Staff" src="http://growinggood.com/wp-content/uploads/2014/02/billboard-slider-images.jpg" />
<span class="caption">Meet The Staff</span></a>
[/fourcol_one]
[fourcol_one_last]
<a href="#" class="caption">
<img class="hover" alt="Portal" src="http://growinggood.com/wp-content/uploads/2014/02/billboard-slider-images.jpg" />
<span class="caption">Portal</span></a>
[/fourcol_one_last]
Here is my css
a.caption{
position:relative;
}
a:hover img.hover{
opacity: 0.5;
filter: alpha(opacity=530);
}
span.caption{
color: #fff !important;
position: absolute;
bottom: 0;
left: 2%;
padding: 1.9%;
width: 93%;
background-color: rgba(0,0,0,0.5);
}
.last span.caption{
bottom: 22px;
left: 3px;
}
Any help is appreciated. Thank you in advance!!

I figured it out!! I had some extra spaces/breaks in the HTML which was making the first 3 columns different than the last. I added/changed a couple of things to span.caption and deleted the CSS for .last span.caption
span.caption{
color: #fff !important;
position: absolute;
padding: 1.9%;
width: 93.5%;
background-color: rgba(0,0,0,0.5);
display: block; /* added */
bottom: 0; /* changed */
left: 3px; /* changed */
}
Thanks to anyone who may have done any research!!

Related

CSS notification style badge over image

I'm attempting to place a 'notification' style badge over an images. I am using Twitters Bootstrap as a base framework and creating a custom CSS class called notify-badge. But I cannot get anything to line up properly.
Through the magic of Photoshop, here is what I am trying to accomplish.
Here is my CSS code.
.notify-badge{
position: absolute;
background: rgba(0,0,255,1);
height:2rem;
top:1rem;
right:1.5rem;
width:2rem;
text-align: center;
line-height: 2rem;;
font-size: 1rem;
border-radius: 50%;
color:white;
border:1px solid blue;
}
I would like to be able to place any small about of text in the badge and it expand the red circle to fit.
Here is my HTML code.
<div class="col-sm-4">
<a href="#">
<span class="notify-badge">NEW</span>
<img src="myimage.png" alt="" width="64" height="64">
</a>
<p>Some text</p>
</div>
Bunch of different ways you can accomplish this. This should get you started:
.item {
position:relative;
padding-top:20px;
display:inline-block;
}
.notify-badge{
position: absolute;
right:-20px;
top:10px;
background:red;
text-align: center;
border-radius: 30px 30px 30px 30px;
color:white;
padding:5px 10px;
font-size:20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-sm-4">
<div class="item">
<a href="#">
<span class="notify-badge">NEW</span>
<img src="https://picsum.photos/200" alt="" />
</a>
</div>
</div>
Addendum (from the Asker #user-44651)
(moved from the question)
Here is the result of applying this answer.
Adding margin-top:-20px; to .item fixed the alignment issue.
The idea here is to overlay an absolute container on top of a relative one. Here's a similar example:
<div class="image">
<img src="images/3754004820_91a5c238a0.jpg" alt="" />
<h2>A Movie in the Park:<br />Kung Fu Panda</h2>
</div>
The CSS:
.image {
position: relative;
width: 100%; /* for IE 6 */
}
h2 {
position: absolute;
top: 200px;
left: 0;
width: 100%;
}
This is going to put our text right up on top of the image nicely, but it doesn't accomplish the box we want to achieve behind the text. For that, we can't use the h2, because that is a block level element and we need an inline element without an specific width. So, wrap the h2 inside of a span.
<h2><span>A Movie in the Park:<br />Kung Fu Panda</span></h2>
Then use that span to style and text:
h2 span {
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgb(0, 0, 0); /* fallback color */
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
For ideas on how to ensure proper spacing or to use jQuery to cleanup the code a bit by allowing you to remove some of the tags from the code and jQuery them back in, check the source.
Here's a fiddle I made with the sample code:
https://jsfiddle.net/un2p8gow/
I changed the notify-badge span into a div. I saw no reason it had to be a span.
I changed the position to relative. Edit - you could actually keep the attribute position: absolute; provided you know what you're doing with it. Guy in the comments was right.
You had the attribute right: 1.5rem; and I simply changed it to left because it was being inset in the opposite direction of your example.
You can tweak it further but in a vacuum this is what you want.

<hr> Line appearing below relative div

I'm currently creating a website which is created by three main divs on one page. In-between each div, I have a faint hr to help visually 'split them up'.
Between my first and second divs, the hr displays fine.
Between the second and third is my problem - the hr displays underneath the second div. I have a feeling it is to do with the relative positioning of the container of my second div, but that is needed for me to position images within in.
I have tried display:block and wrapping the second div inside another container amongst other things, but nothing has yet worked.
I could try using div with a background/border rather than hr, but i'm not sure if this is the right way to approach it (i'm still learning my way around things).
Below is my code for the 'second div' and the hr I am trying to position.
<!-- PORTFOLIO -->
<div id="portfoliocont">
<div class="smallthumb" id="thumb1">
<a href="media/pamabest/pamabesttitle-large.jpg" class="overlay" data-lightbox="image-1" data-title="Pamabest" class="show">
<a href="media/pamabest/app-login.jpg" class="overlay" data-lightbox="image-1" data-title="Log in with your own account">
<a href="media/pamabest/tutorial.jpg" class="overlay" data-lightbox="image-1" data-title="Message your friends">
<a href="media/pamabest/app-profile.jpg" class="overlay" data-lightbox="image-1" data-title="Create your own profile">
<a href="media/pamabest/app-messages.jpg" class="overlay" data-lightbox="image-1" data-title="Message your friends">
<a href="media/pamabest/karaoke--menu.jpg" class="overlay" data-lightbox="image-1" data-title="Have a laugh">
<a href="media/pamabest/lists-viewlist.jpg" class="overlay" data-lightbox="image-1" data-title="Be prepared">
<a href="media/pamabest/mycar.jpg" class="overlay" data-lightbox="image-1" data-title="See the stats">
<a href="media/pamabest/weather.jpg" class="overlay" data-lightbox="image-1" data-title="Pack wisely">
<a href="media/pamabest/ticket5pariswhitestarstextured.jpg" class="overlay" data-lightbox="image-1" data-title="Front of 'Pamabest: Paris' ticket">
<a href="media/pamabest/ticketbackwhitestarstextured.jpg" class="overlay" data-lightbox="image-1" data-title="Back of 'Pamabest: Paris' ticket">
<a href="media/pamabest/travelticket2withbannertextured.jpg" class="overlay" data-lightbox="image-1" data-title="Front of 'Pamabest: Travel Pass' ticket">
<a href="media/pamabest/travelticket2backtextured.jpg" class="overlay" data-lightbox="image-1" data-title="Front of 'Pamabest: Travel Pass' ticket">
<img src="images/smallthumb/pamabest-small.jpg" alt="Imaginary music festival, Pamabest"/ title="Pamabest companion app">
<h1>"Pamabest" is a European, multi-cultural music festival aimed at 18-30 year olds.<br>A companion app would be used to help festival goers navigate the park and enhance their overall experiance.</h1></a>
<p>Pamabest music festival</p>
</div>
<div class="smallthumb" id="thumb2">
<a href="media/pisforpsychohd.mov" class="overlay">
<img src="images/smallthumb/psycho-small.jpg" alt="2 Minute video recreating a scene from the move, P is for Psycho" title="P is for Psycho video"/>
<h1>Filmed within a group, the video is a recreation of the 'bathroom scene' from the movie. <br>All editing was made in Premier Pro.</h1></a>
<p>P is for Pscyho</p>
</div>
<div class="smallthumb" id="thumb3">
<a href="media/silverlake/build/index.html" class="overlay" target="_blank">
<img src="images/smallthumb/silverlake-small.jpg" alt="Silverlake Website" title="Silverlake theme park website"/>
<h1>Silverlake theme park is based in the heart of Yorkshire, boasting a zoo and other child-friendly features. <br> The website was made with HTML5 and CSS3, graphical assests were made in Photoshop and Illustrator.</h1></a>
<p>Silverlake themepark</p>
</div>
<div class="blankthumb" id="thumb4"></div>
<div class="blankthumb" id="thumb5"></div>
<div class="blankthumb" id="thumb6"></div>
</div>
<hr>
And my CSS
hr {
margin: 40px 0px;
border: none;
height: 1px;
color: #ececec; /* old IE */
background-color: #ececec; /* Modern Browsers */
}
/* PORTFOLIO
--------------------------*/
#portfoliocont {
position: relative;
margin-bottom: 40px;
display: block;
}
.smallthumb, .blankthumb {
display: inline-block;
position: absolute;
}
.smallthumb a {
text-decoration: none;
}
.smallthumb img {
-webkit-box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.23);
-moz-box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.23);
box-shadow: 0px 0px 3px 1px rgba(0,0,0,0.23);
}
.blankthumb {
background: #f2f2f2;
width: 296px;
height: 174px;
}
#thumb1 {
left: 0px;
top: 0px;
}
#thumb2 {
left: 335px;
top: 0px;
}
#thumb3 {
right: 0px;
top: 0px;
}
#thumb4 {
left: 335px;
top: 250px;
}
#thumb5 {
right: 0px;
top: 250px;
}
#thumb6 {
left: 0px;
top: 250px;
}
#portfoliocont p {
padding-top: 10px;
color: #808080;
font-weight: 400;
}
.overlay h1 {
position: absolute;
/*display: inline-block;*/
height: 164px;
width: 276px;
bottom: 0;
top: 0;
color: white;
background-color: #806d9e;
opacity: 0;
font: 1em "Helvetica Neue";
text-align: left;
padding: 10px 10px 0px 10px;
line-height: 1.4em;
transition: transform 0.3s, opacity 0.3s;
-ms-transition: -ms-transform 0.3s, opacity 0.3s;
-webkit-transition: -webkit-transform 0.3s, opacity 0.3s;
}
.overlay h1 br{
display: block;
line-height: 2em;
}
.overlay:hover h1{
opacity: 1;
}
#thumb1 a.show {
display: block;
}
#thumb1 a {
display: hidden;
}
Thanks
Your problem here is all the thumbs with position: absolute;
When the browser renders an element with position: absolute; it doesn't take any space.
In your case, the #portfoliocont "has nothing inside".. What I mean is that anything inside that div occupies any space. Therefore, it's height is zero.
Following your zero-height div, the browser continues to render the <hr /> tag.
I strongly recommend not to position your thumbs absolutely. You have many other options, such as:
Display inline-block
Float left
Flexbox (watch out for browser support on this one)
Here is a simple example of using inline-block for the thumbs: https://jsfiddle.net/Lfhctqkg/
Defining div height, solved this little problem for me. An easier way, at least for a student on a simple task.

Overlaying a Image with CSS

I have a store with a gallery. I was looking to overlay the Thumbnail if a Sold stamp that I made.
If i disable the image the overlay is showing bellow, so I know it is inserting the image, it isn't on top though.
What I see:
How I know the overlay is below (thumbnail disabled):
HTML:
<li class="post-66 product type-product status-publish has-post-thumbnail sold-individually shipping-taxable purchasable product-type-simple outofstock">
<center>
<a href="http://url.com">
<img width="150" height="150" src="thumbnail.jpg" class="attachment-shop_catalog wp-post-image" alt="coelho1" />
<h3>Coelho de Peluxe</h3>
</a>
</center>
</li>
CSS:
.outofstock {
background: url("soldoverlay.png") top left no-repeat;
position: relative;
z-index: 200;
}
.attachment-shop_catalog{
z-index: 1;
}
Can anyone please help me?
Kind Regards
The best way to make an overlay is use a pseudo-element using the class you already have outofstock. Check this snippet as an example:
li {
position: relative;
display: inline-block;
white-space: nowrap;
text-align:center;
margin:10px;
}
.outofstock:after {
content: " ";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, .6);
z-index: 10;
}
<ul>
<li>
<a href="http://url.com">
<img width="150" height="150" src="http://placehold.it/150" alt="coelho1" />
<h3>WITHOUT OVERLAY</h3>
</a>
</li>
<li class="outofstock">
<a href="http://url.com">
<img width="150" height="150" src="http://placehold.it/150" alt="coelho1" />
<h3>OVERLAY</h3>
</a>
</li>
</ul>
Edit
To keep the link to of the href you can create the pseudo-element inside the a tag like this:
li {
display: inline-block;
white-space: nowrap;
text-align: center;
margin: 10px;
}
a {
position: relative;
display:block;
}
.outofstock a:after {
content: " ";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, .6);
z-index: 10;
}
<ul>
<li>
<a href="http://url.com">
<img width="150" height="150" src="http://placehold.it/150" alt="coelho1" />
<h3>WITHOUT OVERLAY</h3>
</a>
</li>
<li class="outofstock">
<a href="http://url.com">
<img width="150" height="150" src="http://placehold.it/150" alt="coelho1" />
<h3>OVERLAY</h3>
</a>
</li>
</ul>
you could avoid to use an image and play with CSS 2D transformations (supported even on IE9)
e.g. http://codepen.io/anon/pen/NPydBP
Markup
<ul>
<li data-in-stock="vendido">
<a href="">
<img src="http://dummyimage.com/400x280/cccccc/fff.jpg" />
</a>
</li>
</ul>
CSS
li {
position: relative;
overflow: hidden;
}
[data-in-stock]:after {
position: absolute;
top: 0;
left: 0;
z-index: 1;
content: attr(data-in-stock);
display: block;
min-width: 160px;
color: #fff;
background: #222;
padding: 6px 10px;
text-transform: uppercase;
font: 1em Arial;
-webkit-transform: rotate(-42deg) translateX(-50px);
-moz-transform: rotate(-42deg) translateX(-50px);
transform: rotate(-42deg) translateX(-50px);
}
The text overlapped comes from the data-in-stock attribute in the markup, so you can easily change the text or optionally serve a different page language
This approach could also work if you need to show an image instead of a text (the content property also accepts an url to an image): see http://codepen.io/anon/pen/dPdNBQ
Final Result
1) Create a DIV to place your image in, set left and top css, and set z-index to 5, set width and height to be same as image
2) Create another DIV with same left, top, width, and height, but set z-index higher. Place img tag with outofstock in it

An image keeps going below the rest of the images in a group div?

I have a collection of images sorted into three groups; a group with all the images, a group with the first half of the images and a group of the second half of the images. I want to put the images in a line, but the last image keeps dropping to the bottom... how do I fit this is the same line?`
#firstlot {
z-index: 10;
position: absolute;
left: 61%;
top: 3.5%;
}
#secondlot {
z-index: -5;
position: absolute;
left: 61%;
top: 3.5%;
}
#home {
width: 17.5%;
}
#home2 {
width: 17.5%;
}
#thecoopertimes {
width: 38.5%;
}
#thecoopertimes2 {
width: 38.5%;
}
#aboutme {
width: 25%;
}
#aboutme2 {
width: 25%;
}
#contact {
width: 21%;
}
#contact2 {
width: 21%;
}
<div id="allbuttons">
<div id="firstlot">
<a href="http://www.coopertimewell.com/index">
<img id="home" src="coopertimewell/buttons/home1.png" />
</a>
<a href="http://www.coopertimewell.com/thecoopertimes.html">
<img id="thecoopertimes" src="coopertimewell/buttons/coopertimes1.png" />
</a>
<a href="http://www.coopertimewell.com/aboutme.html">
<img id="aboutme" src="coopertimewell/buttons/aboutme1.png" />
</a>
<a href="http://www.coopertimewell.com/contact.html">
<img id="contact" src="coopertimewell/buttons/contact1.png" />
</a>
</div>
<div id="secondlot">
<a href="http://www.coopertimewell.com/index">
<img id="home2" src="coopertimewell/buttons/home22.png" />
</a>
<a href="http://www.coopertimewell.com/thecoopertimes.html">
<img id="thecoopertimes2" src="coopertimewell/buttons/coopertimes22.png" />
</a>
<a href="http://www.coopertimewell.com/aboutme.html">
<img id="aboutme2" src="coopertimewell/buttons/aboutme22.png" />
</a>
<a href="http://www.coopertimewell.com/contact.html">
<img id="contact2" src="coopertimewell/buttons/contact22.png" />
</a>
</div>
</div>
I know when you look at the code you will say to make an unsorted list instead, but I'm doing it this way for a reason.
It's because you have extra spaces in your code, check here :
Removing whitespace between HTML elements when using line breaks
Thus you can remove them or give a smaller width for each elements.
Example, if you don't format the HTML you won't have your problem:
<img id="home2" src="coopertimewell/buttons/home22.png" /><img id="thecoopertimes2" src="coopertimewell/buttons/coopertimes22.png" />
The problem is that if you adds all the numbers % on your images, it provides over 100%. Then you have space between your images, which you should also take into account.
I have tried and it resolves itself when you corrects the numbers.
Please try a vertical-align:top; to all div that is getting aligned to bottom

How to move the text a bit up and to the right?

How it should be: http://prntscr.com/59nrxz
How it is: http://prntscr.com/59nsfg
My HTML:
<div class="col-md-6 logo" id="header-logo">
<a href="{{ path('static_page', {template:'home'}) }}" title="Return Home">
<img alt="logo" src="static/img/Risne-Logo.png"></img>
<span class="logo_left">RISNE</span>
<span class="logo_right">STARS</span>
</a>
</div>
My CSS:
.logo_left, .logo_right {
font-family: "Droid Sans";
font-size: 34px;
top: -20px;
}
.logo_right {
color: #FECD0F;
}
.logo_left {
color: #234371;
}
I don't care about font or anything, i just need to get the text to move to the right position.
Depending on what you want, a simple position: relative could do the trick.
.logo{
position: relative;
top: -20px; /* This will move it 20px up */
left: 20px; /* This will move it 20px to the right */
}
That'a assuming that you put both of your span's in a div (or heading) that has a class of logo.
Try this it might do the trick :
.logo_left, .logo_right{
vertical-align : top;
margin-left : 10px;
}