Trying to put a container over a image - html

im trying to put a div above a imagem, this div is a white box, and inside this div there are a title and a paragraph element, but im struggling to make the white box appear, the text appear, but the white box doesn't appear at all.
Here is the code of the section im trying to do this, the div has a name of "info-container". I could put the text over the image, but the white box is not appearing, can you help me?
HTML:
<div class="row">
<h1>SEE YOUR TOP ARTISTS</h1>
</div>
<ul class="artists-showcase Clearfix">
<li>
<figure class="artist-photo">
<img src="img/logic.jpg" alt="Logic">
<div class="info-container">
<h4>LOGIC</h4>
<p>Twitter-API</p>
</div>
</figure>
</li>
<li>
<figure class="artist-photo">
<img src="img/avicci.jpg" alt="Avicci">
<div class="info-container">
<h4>LOGIC</h4>
<p>Twitter-API</p>
</div>
</figure>
</li>
<li>
<figure class="artist-photo">
<img src="img/ed_sheeran.jpg" alt="Ed Sheeran">
<div class="info-container">
<h4>LOGIC</h4>
<p>Twitter-API</p>
</div>
</figure>
</li>
<li>
<figure class="artist-photo">
<img src="img/eminem.jpg" alt="Eminem">
<div class="info-container">
<h4>LOGIC</h4>
<p>Twitter-API</p>
</div>
</figure>
</li>
</ul>
CSS:
.section-artists {
padding: 0;
}
.artists-showcase {
list-style: none;
display: inline-block; /* Alinhamento centro */
width: 110%; /* Alinhamento centro */
margin-left: -5%; /* Alinhamento centro e full width */
height: 100%;
margin-top: 5%;
}
.artists-showcase li {
display: block;
transform: skewX(-10deg);
float: left;
width: 25%;
height: 100%;
}
.artist-photo {
width: 100%;
height: 100%;
margin:0;
overflow: hidden;
background-color: #000;
}
.artist-photo img {
opacity: 0.7;
width: 150%;
height: auto;
-webkit-transform: scale(1.18) skewX(10deg); /* reverte o skew para a imagem ficar reta */
transform: skewX(10deg);
-webkit-transition: opacity 0.5s, -webkit-transform 0.5s;
transition: opacity 0.5s, -webkit-transform 0.5s, filter 0.5s;
transition: transform 0.5s, opacity 0.5s, filter 0.5s;
transition: transform 0.5s, opacity 0.5s, -webkit-transform 0.5s, filter 0.5s;
transition: transform 0.5s, opacity 0.5s, -webkit-transform 0.5s, filter 0.5s;
}
//*.artist-photo img:hover {
// opacity: 1;
// -webkit-transform: scale(1.03) skewX(10deg);;
// transform: scale(1.03) skewX(10deg);
// filter: hue-rotate(250deg);
/*/
/* Container com texto e titulo */
.info-container {
background: #fff;
width: 500px;
height: auto;
top: 50%;
padding: 0;
margin-bottom: -20%;
z-index: 1000;
}
.info-container>h4 {
float: left;
position: absolute;
top: 50%;
left: 10%;
z-index: 1000;
}
.info-container>p {
float: left;
position: absolute;
top: 55%;
left: 10%;
z-index: 1000;
}
Thank you very much in advance!

ok So here is my try,
first add overflow to the info-container and add position absolute to it and use margins h4 and p for alignment.
.artist-photo {
position: relative
}
.info-container {
position:absolute;
top: //As per need;
overflow: hidden;
}
Remove position absolute from h4 and p use margins to align it
.info-container>h4 {
float: left;
margin-right: 10px;
}
.info-container>p {
float: left;
}

Related

Is there any way I can shift the whole html canvas to the left or right making room for a sidebar menu on mobile?

I saw many apps that can do this: When you click a menu expand icon. The whole content moves to the right or left. making some room for the menu.
Is it possible to shift the whole existing page to the right or left out of the screen, making room for the menu? If so, how can I achieve it with CSS or JavaScript?
JS Below
$(document).ready(function() {
$('.menu-switch').draggable({containment: "parent"});
$('.menu-switch').click(function(){
$('.content').toggleClass('show-menu');
});
$('.left-menu span').click(function(){
$('.content').toggleClass('show-menu');
});
})
CSS Below
.content {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
-webkit-transition: -webkit-transform 0.3s linear;
transition: -webkit-transform 0.3s linear;
transition: transform 0.3s linear;
transition: transform 0.3s linear, -webkit-transform 0.3s linear;
}
.content.show-menu {
-webkit-transform: translateX(200px);
transform: translateX(200px);
-webkit-transition: -webkit-transform 0.3s linear;
transition: -webkit-transform 0.3s linear;
transition: transform 0.3s linear;
transition: transform 0.3s linear, -webkit-transform 0.3s linear;
}
.content .inner-content {
position: relative;
top: 50%;
left: 50%;
width: 60%;
padding: 20px 30px;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.content .menu-switch {
position: absolute;
z-index: 1;
left: 2%;
top: 2%;
padding: 10px 13px;
background:#999;
border-radius: 50%;
}
.content .left-menu {
text-align: center;
position: absolute;
box-sizing: border-box;
left: -200px;
width: 200px;
height: 100%;
}
.content .left-menu span {
position: absolute;
left: 2%;
top: 2%;
}
.content .left-menu .left-menu-content a {
display: block;
}
HTML Below
<div class="content">
<aside class="left-menu">
<span class="fa fa-times-circle fa-lg fa-fw fa-inverse"></span>
<div class="left-menu-header">
<h3>My Menu<h3>
<hr />
</div>
<div class="left-menu-content">
Menut Item 1
</div>
</aside>
<nav class="menu-switch">
<span class="fa fa-navicon fa-2x fa-inverse f-fw"></span>
</nav>
<div class="inner-content">
<p>Page Content Would be over here</p>
</div
</div>
You can solve the problem with an CSS animation that overlays the whole screen.
Have a look at the 9th example from Eduard L. in the link below you can pretty much do the same thing you only need to adjust the navbar how you like it and make the animation way bigger.
https://freefrontend.com/css-sidebar-menus/

How to center a burger icon vertically inside a div?

I have a navigation menu that contains a burger icon made with 3 <span> that is inside another elements :
.navbar {
width: 100%;
color: #fff;
background-color: #df0024;
padding: 1% 0;
}
.tog {
display: flex;
cursor: pointer;
float: right;
width: 6%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
align-items: center;
justify-content: center;
height: auto;
}
/*This is the div that contain the burger 3 layers*/
#nav-icon {
height: -webkit-fill-available;
height: -moz-fill-available;
height: -o-fill-available;
height: fill-available;
position: relative;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
}
/*/The style of each of the burger icon 3 layers*/
#nav-icon span {
display: block;
position: absolute;
height: 3.1vh;
width: 100%;
background: white;
border-radius: 9px;
opacity: 1;
left: 0;
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
#nav-icon span:nth-child(1) {
top: 0px;
}
#nav-icon span:nth-child(2) {
top: 12px;
}
#nav-icon span:nth-child(3) {
top: 24px;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo' />
</div>
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
How to center the #nav-icon span inside the #nav-icon vertically ? All I want is centering the burger icon so I don't care of changing the other elements style that contain the burger icon.
I had to tweak a lot to make this work, but I used a nice vertical-centering trick I know involving top: 50%; plus transition: translateY(-50%);. If you apply those to a child div then it will be vertically centered within a sized parent (the parent should also have position relative or absolute).
I applied these styles to the .icon-container in your code.
.navbar{
width: 100%;
position: relative;
color: #fff;
background-color: #df0024;
padding: 1% 0;
}
.tog {
display: flex;
cursor: pointer;
float: right;
width: 6%;
position: absolute;
top: 0;
right: 0;
bottom: 0;
align-items: center;
justify-content: center;
height: auto;
}
/*This is the div that contain the burger 3 layers*/
#nav-icon{
position: absolute;
top:0;
bottom:0;
left:0;
right: 0;
-webkit-transition: .5s ease-in-out;
-moz-transition: .5s ease-in-out;
-o-transition: .5s ease-in-out;
transition: .5s ease-in-out;
cursor: pointer;
}
.icon-container {
padding: 0 5px;
box-sizing: border-box;
position: relative;
top: 50%;
-ms-transform: translateY(-50%); /* IE 9 */
-webkit-transform: translateY(-50%); /* Chrome, Safari, Opera */
transform: translateY(-50%);
}
#nav-icon span{
display: block;
width: 100%;
height: 5px;
margin-bottom: 3px;
background: white;
border-radius: 9px;
opacity: 1;
-webkit-transition: .25s ease-in-out;
-moz-transition: .25s ease-in-out;
-o-transition: .25s ease-in-out;
transition: .25s ease-in-out;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo'/>
</div>
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>
If you have nothing against flex, you may also drop the absolute positionning.
.navbar {
display: flex;
align-items: center;/* vertical-centering */
color: #fff;
background-color: #df0024;
padding: 1% 0;
/* DEMO PURPOSE ONLY to show vertical centering */
transition:0.25s;
height: 100px;
background-image:linear-gradient(to top, transparent 50%, rgba(255,255,255,0.15) 50%);
}
.navbar:hover {height:200px;}
/* end -- DEMO PURPOSE ONLY to show vertical centering */
nav a {
/* demo purpose , useless about centering */
margin: 0 0.5em;
color: white;
}
.tog {
cursor: pointer;
width: 1.5em;
margin-left: auto;/* goes all the way to the right side */
}
/*This is the div that contain the burger 3 layers*/
#nav-icon {
display: block;
transform: rotate(0deg);
transition: .5s ease-in-out;
cursor: pointer;
}
/*The style of each of the burger icon 3 layers*/
#nav-icon span {
display: block;
background: white;
margin: 0.25em 0;
border-radius: 9px;
opacity: 1;
height: 0.25em;
transform: rotate(0deg);
transition: .25s ease-in-out;
box-shadow: 1px 1px 1px;
}
<nav class="navbar">
<div class="logo">
<img src="" alt='Logo' />
</div>
another link ?
<div id='tog' class="tog">
<label for="toggle" id='nav-icon'>
<div class='icon-container'>
<span></span>
<span></span>
<span></span>
</div>
</label>
</div>
</nav>

How do I stack images on top of each other wrapped in the same div, and then have them separate with animation when I hover?

HTML:
<div class="mySlides">
<img src="1.jpg">
<img src="2.jpg"/>
<img src="3.jpg"/>
<img src="4.jpg"/>
<img src="5.jpg"/>
</div>
CSS:
.mySlides {
padding-top: 25%;
padding-left: 5%;
}
.mySlides img {
object-fit: cover;
position: absolute;
max-width: 35%;
}
.mySlides img:nth-of-type(1) {
left: 0%;
top: 0%;
-webkit-transform: rotate(5deg);
-moz-transform: rotate(5deg);
-o-transform: rotate(5deg);
transform: rotate(5deg);
}
This will be repeated for all images, i.e. nth-of-type(2,3,4,5)
.mySlides img {
-webkit-transition: all 0.25s ease-out;
-moz-transition: all 0.25s ease-out;
-o-transition: all 0.25s ease-out;
transition: all 0.25s ease-out;
padding: 10px 10px 30px 10px;
background: linear-gradient(#ffffff, #eaeaea);
border: solid 1px black;
}
I wanted to stack the images on top of each other and have them all centered on the screen.
On hovering I wanted the images to separate horizontally while still maintaining the animation.
Check this out
Working fiddler https://jsfiddle.net/RaajNadar/L0ennqwp/
Html
<div class="mySlides">
<img src="http://lorempixel.com/400/200/">
<img src="http://lorempixel.com/400/200/sports"/>
</div>
css
.mySlides {
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
max-width: 300px;
transition: left 1.2s ease-in-out;
}
.mySlides:hover img:last-child {
left: 300px;
}
Also got a nice animation.
Is this what you need?
.mySlides {
display: flex;
position: relative;
}
.mySlides img {
position: absolute;
top: 0;
left: 0;
}
.mySlides:hover img {
position: relative;
top: auto;
left: auto;
}
<div class="mySlides">
<img src="http://placehold.it/300x150/000000">
<img src="http://placehold.it/300x150/003300" />
<img src="http://placehold.it/300x150/00ff00" />
<img src="http://placehold.it/300x150/006600" />
<img src="http://placehold.it/300x150/ff0000" />
</div>

Vertically centering and animating icon on image hover

I have trouble vertically centering icon that drops on image hover, and I am trying to ease out its drop down. Currently it is coming down too aggressive but no matter what transition property I set (ease, ease-out etc.) it doesn't change.
https://jsfiddle.net/4br7sj0q/2/
<div class="fader">
<a href="#">
<img width="200" height="350" src="http://placehold.it/200x350">
<span class="fa fa-search fa-3x"></span>
</a>
</div>
.fader {
position: relative;
span.fa {
position: absolute;
top: -9999px;
// center horizontal
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
transition: all 0.3s ease-out;
}
&:hover .fa {
top: 50%;
}
}
Couple of things.
The icon is coming a long way. You really don't need to send it 9999px away, just enough to be offscreen (or apply overflow hidden to the parent and then it can just be 1em off the top).
Then change the transition to something like transition: all 0.5s ease;...if it's too fast, make the time longer.
The easing function should just be ease...not ease-out...it looks more natural.
Finally, to adjust the centering you need to drag it back up half it's own height
transform:translateY(-50%);
li {
list-style: none;
text-align: center;
}
.fader {
position: relative;
overflow: hidden;
display: inline-block;
}
.fader img {
-webkit-transition: all 0.3s;
transition: all 0.3s;
display: block;
}
.fader img:hover {
opacity: 0.5;
}
.fader span.fa {
color: #333;
position: absolute;
top: -1em;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
-webkit-transition: all .5s ease;
transition: all .5s ease;
-webkit-transform: translateY(-50%);
transform: translateY(-50%);
}
.fader:hover .fa {
top: 50%;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet" />
<li>
<div class="fader">
<a href="#">
<img width="200" height="350" src="http://placehold.it/200x350"> <span class="fa fa-search fa-3x"></span>
</a>
</div>
</li>
Your top value is insanely high ;)
Just change it to a more reasonnable value to hide it and it should be good for you :
span.fa {
color: #333;
position: absolute;
top: -60px;
margin-left: auto;
margin-right: auto;
left: 0;
right: 0;
transition: all 0.3s ease-out;
}
Fiddle

Adding a rollover only works on one image div

I am creating a rollover on an image div where once you roll over, the image opacity goes down and text over the top appears. This works fine for just one image, but when trying it on more then one image the opacity doesn't work correctly and the text doesn't seem to appear on the other images.
HTML:
<div class="worklongdiv" style="padding-top:111px";>
<img src="images/Vividworklong.jpg"/>
<div class="work-text-content-long">
<header>VIVID VAPOURS</header>
<p style="font-size:17px; font-family:GothamRoundedBold;">Branding • Product Dev • Web Dev</p>
</div>
</div>
<div class="worklongdiv" >
<img src="images/Vividworklong.jpg"/>
<div class="work-text-content-long">
<header>VIVID VAPOURS</header>
<p style="font-size:17px; font-family:GothamRoundedBold;">Branding • Product Dev • Web Dev</p>
</div>
</div>
CSS:
.worklongdiv{
width: 100%;
min-height: 120px;
max-height:auto
position: relative;
background-color: black;
}
.worklongdiv:hover img {
opacity: 0.3;
}
.worklongdiv:hover .work-text-content-long {
opacity: 1;
}
.worklongdiv img {
padding: 0;
width: 100%;
display: block;
opacity: 1;
}
.worklongdiv img,
.work-text-content-long {
-webkit-transition: opacity 0.5s ease-out;
-moz-transition: opacity 0.5s ease-out;
-o-transition: opacity 0.5s ease-out;
transition: opacity 0.5s ease-out;
}
.work-text-content-long {
height:100px;
position: absolute;
color: white;
left: 0;
top: 25%;
right: 0%;
left:101px;
bottom: 0;
font-size: 24px;
text-align: left;
opacity: 0;
}
You're missing a ; in one of your CSS rules.
.worklongdiv{
width: 100%;
min-height: 120px;
max-height:auto;
position: relative;
background-color: black;
}