I'm adapting a portfolio code that was kindly posted by James here: http://codepen.io/SeamlessThemes/pen/LiBdo
I've managed to change most things that I need, but I can't for the life of me get the href to cover the responsive block. At the moment only the "View" link and padding are active.
I'll reproduce the code here so that you don't need to visit codepen if you'd rather not
* {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
}
.view {
width: 32.33%;
height: auto;
margin-right: 0px;
float: left;
border: 1px solid #e5e5e5;
overflow: hidden;
position: relative;
text-align: center;
box-shadow: 1px 1px 2px #e6e6e6;
cursor: default;
background: #079;
}
.view:last-child {
margin-right: 0px;
}
.view .mask, .view .content {
width: 32.33%;
height: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0
}
.view img {
display: block;
position: relative;
}
.view h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
font-size: 17px;
padding: 10px;
background: #222;
margin: 20px 0 0 0
}
.view p {
font-family: Georgia, serif;
font-style: italic;
font-size: 12px;
position: relative;
color: #fff;
padding: 10px 20px 20px;
text-align: center
}
.view a.info {
display: inline-block;
text-decoration: none;
padding: 7px 14px;
background: #000;
color: #fff;
text-transform: uppercase;
box-shadow: 0 0 1px #000
}
.view a.info:hover {
box-shadow: 0 0 5px #000
}
.view-portfolio img {
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.view-portfolio .mask {
background-color: #222;
-webkit-transform: translateX(-300px);
-moz-transform: translateX(-300px);
-o-transform: translateX(-300px);
-ms-transform: translateX(-300px);
transform: translateX(-300px);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.view-portfolio h2 {
background: #222;
color: #FFF;
}
.view-portfolio p {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
opacity: 0;
color: #FFF;
-webkit-transition: all 0.2s linear;
-moz-transition: all 0.2s linear;
-o-transition: all 0.2s linear;
-ms-transition: all 0.2s linear;
transition: all 0.2s linear;
}
.view-portfolio:hover .mask {
-webkit-transform: translateX(0px);
-moz-transform: translateX(0px);
-o-transform: translateX(0px);
-ms-transform: translateX(0px);
transform: translateX(0px);
}
.view-portfolio:hover img {
-webkit-transform: translateX(300px);
-moz-transform: translateX(300px);
-o-transform: translateX(300px);
-ms-transform: translateX(300px);
transform: translateX(300px);
}
.view-portfolio:hover p {
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
opacity: 1;
}
<div class="view view-portfolio">
<img src="http://locallylost.com/chun/files/2013/01/manhattansummer.jpg">
<div class="mask">
<h2>Portfolio Item 1</h2>
<p>This is an example portfolio item exceprt.</p>
View
</div>
</div>
<div class="view view-portfolio">
<img src="http://locallylost.com/chun/files/2013/01/manhattansummer.jpg">
<div class="mask">
<h2>Portfolio Item 2</h2>
<p>This is another example portfolio item exceprt.</p>
View
</div>
</div>
<div class="view view-portfolio">
<img src="http://locallylost.com/chun/files/2013/01/manhattansummer.jpg">
<div class="mask">
<h2>Portfolio Item 3</h2>
<p>This is yet another example portfolio item exceprt.</p>
<a href="#" class="info">View</>
</div>
</div>
.view a.info {
position: absolute;
z-index: 10;
bottom: 0;
width: 100%;
height: 100%;
left: 0;
right: 0;
top: 0;
}
You can adjust it accordingly.
I don't really understand the question but if you want a link on the image...
<div class="view view-portfolio">
<a href="http://www.w3schools.com/html/">
<img src="http://locallylost.com/chun/files/2013/01/manhattansummer.jpg">
</a>
<div class="mask">
<h2>Portfolio Item 1</h2>
<p>This is an example portfolio item exceprt.</p>
View
</div>
</div>
Related
I would like to achieve the following effect: below CSS, on hover, does a "slot machine effect" that rolls the icon in a vertical carousel (please see the css below for details).
Due to restrictions of hosting that I am using for my website, I cannot use any external library of icons, so I would like to achieve the same effect, pasting the css into the header and using it with an img tag in HTML.
Could you please help me trim this css so that it will actually work with my image?
Thank you for all your forbearance and help.
-webkit-transition:all .3s;
-o-transition:all .3s;
transition:all .3s
}
.btn.social_share:hover .social-media-share-buttons-icon:before {
top: 40px;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s
}
.btn.social_share:hover .social-media-share-buttons-icon:after {
top: 0;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s
}
.btn.social_share:active {
text-decoration: none!important;
-webkit-touch-callout: none
}
.btn.social_share:active .social-media-share-buttons-icon {
background-color: rgba(0, 0, 0, .2);
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s
}
.btn.social_share:active .social-media-share-buttons-icon:before {
top: 40px;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s
}
.btn.social_share:active .social-media-share-buttons-icon:after {
top: 0;
-webkit-transition: all .3s;
-o-transition: all .3s;
transition: all .3s
}
.btn.social_share.facebook .social-media-share-buttons-icon:after,
.btn.social_share.facebook .social-media-share-buttons-icon:before {
content: "\e63f"
}
.btn.social_share.linkedin .social-media-share-buttons-icon:after,
.btn.social_share.linkedin .social-media-share-buttons-icon:before {
content: "\e631"
}
.btn.social_share.twitter .social-media-share-buttons-icon:after,
.btn.social_share.twitter .social-media-share-buttons-icon:before {
content: "\e640"
}
#-moz-keyframes fadeBottom {
0% {
opacity: 0;
-ms-transform: translateY(10%);
-webkit-transform: translateY(10%);
transform: translateY(10%)
}
100% {
opacity: 1;
-ms-transform: translateY(0);
-webkit-transform: translateY(0);
transform: translateY(0)
}
}
#-webkit-keyframes fadeBottom {
0% {
opacity: 0;
-ms-transform: translateY(10%);
-webkit-transform: translateY(10%);
transform: translateY(10%)
}
100% {
opacity: 1;
-ms-transform: translateY(0);
-webkit-transform: translateY(0);
transform: translateY(0)
}
}
#-o-keyframes fadeBottom {
0% {
opacity: 0;
-ms-transform: translateY(10%);
-webkit-transform: translateY(10%);
transform: translateY(10%)
}
100% {
opacity: 1;
-ms-transform: translateY(0);
-webkit-transform: translateY(0);
transform: translateY(0)
}
}
As requested, also adding the HTML snippet, which currently is not working with above css:
<div style="padding: 30px 0; padding-left: 0px; margin-left: 0px; margin-right: 0px; text-align: center">
<div class="col-xs-12">
<ul class="social-media-share-buttons">
<li>
<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https://www.mywebsite.com" class="btn btn-link social_share facebook" rel="nofollow" data-social_name="facebook" data-post_id="" data-social_type="share" data-location="inline">
<img class="social-media-share-buttons-icon" src="facebook_icon.png">
<div style="color: #fff; line-height: 2; font-weight: 700;">Facebook</div>
</a>
</li>
You don't need animations for that. Just use transitions and transforms and it works: Here some example:
ul {
text-align: center;
padding: 0;
}
li {
list-style-type: none;
}
a {
display: inline-block;
position: relative;
height: 40px;
background: #4456aa;
line-height: 40px;
overflow: hidden;
color: white;
text-decoration: none;
font-family: sans-serif;
border: 1px solid transparent;
transition: all 0.5s ease 0.5s;
}
a div {
padding: 0 30px;
}
a img {
transition: all ease 1s;
position: absolute;
top: 100%;
left: 0;
bottom: 0;
width: 30px;
margin: auto;
opacity: 0;
}
a:hover {
transition: all ease 0.5s;
}
a:hover {
background: #ffffff;
border: 1px solid #000000;
color: #000000;
}
a:hover img {
transition: all 0.5s ease 0.5s;
opacity: 1;
top: 0;
bottom: 0;
}
<ul class="social-media-share-buttons">
<li>
<a target="_blank"
href="https://www.facebook.com/sharer/sharer.php?u=https://www.mywebsite.com"
class="btn btn-link social_share facebook"
rel="nofollow"
data-social_name="facebook"
data-post_id=""
data-social_type="share"
data-location="inline">
<img class="social-media-share-buttons-icon"
src="https://image.flaticon.com/icons/png/128/20/20837.png">
<div>Facebook</div>
</a>
</li>
</ul>
You may use pre-built CSS properties like transforms and transitions, maybe they make you independent of animations.
I tried to put some contents over an image with some overlay effects, but it does not shows output as my needs. Also I don't know how to do overlay effects anyone can help me please.
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 9;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.destinationmask {
width: 100%;
height: 100%;
z-index: 5;
opacity: 0.4;
filter: alpha(opacity=50);
background: #000;
}
<img src="https://image.ibb.co/evyyfm/mu.jpg" alt="img01"/>
<a href="" class="overlay-leftTop">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
</div>
</div>
</div>
Actually I need something like this
You should use background-image CSS property instead of <img> tag. And for effects use pseudo elements like :before.
Have a look at the snippet below:
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
display: block;
position: relative;
text-decoration: none;
width: 300px;
height: 300px;
z-index: 9;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 1;
background: rgba(0,0,0,0.3);
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:hover {
text-decoration: none;
}
.overlay-leftTop:hover:before {
background: rgba(0,0,0,0.5);
}
.destinationmask {
width: 100%;
height: 100%;
z-index: 5;
opacity: 0.4;
filter: alpha(opacity=50);
background: #000;
}
<a href="" class="overlay-leftTop" style="background-image: url('https://image.ibb.co/evyyfm/mu.jpg');">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
</div>
</div>
</div>
</a>
Hope this helps!
I think this is what u want.
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
display: block;
position: relative;
text-decoration: none;
width: 300px;
height: 300px;
z-index: 9;
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 1;
background: rgba(0,0,0,0.3);
transition: all .3s ease;
-webkit-transition: all .3s ease;
-moz-transition: all .3s ease;
}
.overlay-leftTop:hover {
text-decoration: none;
}
.overlay-leftTop:hover:before {
background: rgba(0,0,0,0.5);
}
.destinationmask {
width: 100%;
height: 100%;
z-index: 5;
opacity: 0.4;
filter: alpha(opacity=50);
background: #000;
}
.view-btn{
position: absolute;
top: 180px;
font-size: 16px !important;
border: 2px solid #fff;
display: inline-block !important;
text-align: center;
padding: 10px 15px;
opacity: 0;
transition:all 350ms ease 0s;
}
.overlay-leftTop:hover .view-btn{
opacity:1;
}
<a href="" class="overlay-leftTop" style="background-image: url('https://image.ibb.co/evyyfm/mu.jpg');">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
<span class="view-btn">View More</Span>
</div>
</div>
</div>
</a>
Please try this. I have added some css:
.img-wrap {
display: inline-block;
position: relative;
width: 386px;
}
.img-box:before {
position: absolute;
content: "";
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.4);
transform:scale(0);
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
}
.img-wrap:hover .img-box:before {
transform:scale(1);
}
.img-wrap:hover .overlay-leftTop{
opacity:1;
}
img {
height: auto;
max-height: 100%;
max-width: 100%;
width: auto;
display: block;
}
.destination {
padding: 20px;
-ms-transform: translate(0, 0);
-webkit-transform: translate(0, 0);
transform: translate(0, 0);
transition: all .5s ease;
-ms-transition: all .5s ease;
-webkit-transition: all .5s ease;
}
.destination h3 {
font-size: 25px;
color: #fff;
line-height: 20px;
text-transform: uppercase;
margin-bottom: 10px;
}
.destination span {
display: block;
font-size: 15px;
color: #fff;
line-height: 16px;
}
.overlay-leftTop {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
opacity:0;
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
}
.img-wrap {
display: inline-block;
position: relative;
width: 386px;
}
.img-box:before {
position: absolute;
content: "";
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.4);
transform:scale(0);
transition: all .5s ease;
-webkit-transition: all .5s ease;
-moz-transition: all .5s ease;
}
.img-wrap:hover .img-box:before {
transform:scale(1);
}
.img-wrap:hover .overlay-leftTop{
opacity:1;
}
img {
height: auto;
max-height: 100%;
max-width: 100%;
width: auto;
display: block;
}
<div class="img-wrap">
<div class="img-box">
<img src="https://image.ibb.co/evyyfm/mu.jpg" alt="img01"/>
</div>
<a href="" class="overlay-leftTop">
<div class="table-display">
<div class="table-cell table-cell-bottom">
<div class="destination">
<h3>TEST</h3>
<span>Check,check1,check2</span>
</div>
</div>
</div>
</a>
</div>
I want to make a hover effect, when hover the image like this:
On the Internet found many similar examples but they all either with jquery or js. I would like to know whether it is possible to do purely with css...
UPDATE: here's a code found, but it is too big :(
.view-content {
height: 330px;
}
h2.view-title {
font-size: 3rem;
font-weight: bold;
color: #7d7a7a;
text-align: center;
text-shadow: 0 0px 0px;
}
.view {
width: 300px;
height: 200px;
margin: 10px;
float: left;
border: 5px solid #fff;
overflow: hidden;
position: relative;
text-align: center;
box-shadow: 0px 0px 5px #aaa;
cursor: default;
}
.view .view-mask, .view {
width: 300px;
height: 200px;
position: absolute;
overflow: hidden;
top: 0;
left: 0;
}
.view img {
display: block;
position: relative;
}
.view a.view-info {
display: inline-block;
text-decoration: none;
padding:0;
text-align: center;
color: white;
font-size: 1.9rem;
font-weight: 600;
vertical-align: middle;
}
.view-effect .view-mask {
opacity: 0;
overflow:visible;
border:100px solid rgba(0,0,0,0.7);
box-sizing:border-box;
transition: all 0.3s ease-in-out;
}
.view-effect a.view-info {
position:relative;
top:-20px;
opacity: 0;
transition: opacity 0.3s 0s ease-in-out;
}
.view-effect:hover .view-mask {
opacity: 1;
border:100px solid rgba(0,0,0,0.7);
}
.view-effect:hover a.view-info {
opacity:1;
transition-delay: 0.3s;
}
<div class="view view-effect">
<img src="http://storage7.static.itmages.ru/i/16/0708/h_1467979220_8325708_d41d8cd98f.png" height="200" width="300" alt=""> <p></p>
<div class="view-mask">
Show project
</div>
</div>
Checkout below code as what you want or just click on below link :-
https://jsfiddle.net/ananddeepsingh/99bop25r/
HTML
<div class="box"> <img src="http://placehold.it/400x300">
<div class="overbox">
<div class="title overtext"> CSS Script </div>
<div class="tagline overtext"> Animated Text Overlay On Hover </div>
</div>
</div>
CSS
.box {
cursor: pointer;
height: 300px;
position: relative;
overflow: hidden;
width: 400px;
}
.box img {
position: absolute;
left: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.box .overbox {
background-color: #304562;
position: absolute;
top: 0;
left: 0;
color: #fff;
z-index: 100;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
opacity: 0;
width: 360px;
height: 240px;
padding: 130px 20px;
}
.box:hover .overbox {
opacity: 1;
}
.box .overtext {
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
transform: translateY(40px);
-webkit-transform: translateY(40px);
}
.box .title {
font-size: 2.5em;
text-transform: uppercase;
opacity: 0;
transition-delay: 0.1s;
transition-duration: 0.2s;
}
.box:hover .title,
.box:focus .title {
opacity: 1;
transform: translateY(0px);
-webkit-transform: translateY(0px);
}
.box .tagline {
font-size: 0.8em;
opacity: 0;
transition-delay: 0.2s;
transition-duration: 0.2s;
}
.box:hover .tagline,
.box:focus .tagline {
opacity: 1;
transform: translateX(0px);
-webkit-transform: translateX(0px);
}
Yes you can do that using pure CSS. for that purpose you may use :after pseudo class as,
.img-wrapper {
position:relative;
display:inline-block;
overflow:hidden;
cursor:pointer
}
.img-wrapper .hover-div{
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
opacity:0;
display:inline-block;
text-align:center;
background:rgba(0,0,0,0.3);
-webkit-transition: 0.5s ease-in-out;
-moz-transition: 0.5s ease-in-out;
-o-transition: 0.5s ease-in-out;
transition: 0.5s ease-in-out;
-webkit-transform: translateY(100%);
-moz-transform: translateY(100%);
-o-transform: translateY(100%);
-ms-transform: translateY(100%);
transform: translateY(100%);
}
.img-wrapper:hover .hover-div{
top:0;
opacity:1;
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-o-transform: translateY(0);
-ms-transform: translateY(0);
transform: translateY(0);
}
.img-wrapper:hover img {
-webkit-filter:grayscale(1);
-moz-filter:grayscale(1);
filter:grayscale(1);
}
.mybutton{
background:#FFFFFF;
color:#111111;
padding:10px 20px;
border-radius:5px;
display:inline-block;
margin-top:100px;
-webkit-transition: 0.3s ease-in-out;
transition: 0.3s ease-in-out;
}
.mybutton:hover{
background:#111111;
color:#FFFFFF;
}
<div class="img-wrapper">
<img src="https://unsplash.it/200" >
<div class="hover-div">
<a class="mybutton">My Button</a>
</div>
</div>
Just use ':hover' after the element you want to show the effect on. For example, if you wanted to use it on the header you would create a new css tag called
header:hover{} and then you could put an opactiy of maybe 0.5 to make the object fade on hover. Hope this helps!
Yes it is possible only through HTML and CSS. Below there is an example code:
HTML:
<div class="imagebox">
<div class="transparent"><i class="fa fa-search" aria-hidden="true"></i>
<p>Zoom</p></div>
<img src="images/yourimage.jpg">
</div>
CSS:
.imagebox{
position: relative;
}
.imagebox:hover .transparent{
display: block;
}
.transparent{
background: rgba(0,0,0,0.5);
position: absolute;
height: 100%;
width: 100%;
display: none;
cursor: pointer;
}
.transparent i{
position: absolute;
left: 50%;
top: 30%;
color: #fff;
font-size: 20px;
}
.transparent p{
position: absolute;
left: 45%;
top: 50%;
color: #fff;
font-size: 20px;
}
Why is the box shadow not displayed correctly in here:
.panel:hover {
box-shadow: 0px 0px 150px #000000;
z-index: 2;
-webkit-transition: all 200ms ease-in;
-webkit-transform: scale(1.3);
-ms-transition: all 200ms ease-in;
-ms-transform: scale(1.3);
-moz-transition: all 200ms ease-in;
-moz-transform: scale(1.3);
transition: all 200ms ease-in;
transform: scale(1.3);
}
Link to JsFiddle.
On some of the boxes it does not display to the right hand side.
If you want the z-index to work consistently, you need to set position: relative.
html,
body {
height: 100%;
width: 100%;
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAI0lEQVQIW2NkwAT/GdHE/gP5jMiCYAGQIpggXAAmiCIAEgQAAE4FBbECyZcAAAAASUVORK5CYII=) #222;
}
h1 {
color: white;
text-align: center;
}
.container {
width: 80%;
height: 80%;
margin: 0 auto;
border: red;
color: white;
}
.panel {
position: relative; /* ADD THIS */
float: left;
min-width: 30%;
max-width: 30%;
min-height: 30%;
max-height: 30%;
display: flex; /* testing this for aligning text */
justify-content: center; /* align horizontal */
align-items: center; /* align vertical */
background-color: #FF6961;
margin: 1%;
border: white;
color: #222;
-webkit-transition: all 200ms ease-in;
-webkit-transform: scale(1);
-ms-transition: all 200ms ease-in;
-ms-transform: scale(1);
-moz-transition: all 200ms ease-in;
-moz-transform: scale(1);
transition: all 200ms ease-in;
transform: scale(1);
-index: 1;
}
.panel:hover {
box-shadow: 0px 0px 150px 0px white;
z-index: 2;
-webkit-transform: scale(1.3);
transform: scale(1.3);
}
span {
display: inline-block;
vertical-align: middle;
line-height: normal;
}
<h1>
Title Here
</h1>
<div class="container">
<div class="panel">
<span>
Forums
</span>
</div>
<div class="panel">
<span>
News
</span>
</div>
<div class="panel">
Leaderboards
</div>
<div class="panel">
About
</div>
</div>
I am trying to get these div's to center (all 3 next to each other to be in the center of the page), however I cannot get them to center.
Here is how they look, as an example: http://callum.website/
Code:
HTML
<div class="containercontainer">
<div class="containerleft">
<figure class="image-container">
<img src="https://d13yacurqjgara.cloudfront.net/users/430915/screenshots/2031943/untitled-7_1x.png" alt="eSportsy - eSports PSD Template" width="400" height="300">
<figcaption class="clearfix">
<h4>eSportsy - FREE PSD Template</h4>
<p>in <font color="0ead99"><B>FREEBIES</B></font></p>
Download
</figcaption>
</figure>
</div>
<div class="container">
<figure class="image-container">
<img src="https://d13yacurqjgara.cloudfront.net/users/430915/screenshots/2031943/untitled-7_1x.png" alt="eSportsy - eSports PSD Template" width="400" height="300">
<figcaption class="clearfix">
<h4>eSportsy - FREE PSD Template</h4>
<p>in <font color="0ead99"><B>FREEBIES</B></font></p>
Download
</figcaption>
</figure>
</div>
<div class="containerright">
<figure class="image-container">
<img src="https://d13yacurqjgara.cloudfront.net/users/430915/screenshots/2031943/untitled-7_1x.png" alt="eSportsy - eSports PSD Template" width="400" height="300">
<figcaption class="clearfix">
<h4>eSportsy - FREE PSD Template</h4>
<p>in <font color="0ead99"><B>FREEBIES</B></font></p>
Download
</figcaption>
</figure>
</div>
body{
background: #F3F3F3;
margin: 0px;
padding: 0px;
font-family: 'Open Sans', sans-serif;
color: #2A2A2A;
}
h4 {
color: #fff;
margin: 0;
padding: 0;
}
p {
margin: 0;
}
.containercontainer{
width: 66%;
margin: 0 auto;
max-width:100%;
text-align: center;
}
.containerleft {
height: 312px;
width: 412px;
font: 87.5%/1.5em sans-serif !important;
margin-top:20px;
display: inline-block;
text-align:left !important;
float:left;
}
.container {
height: 312px;
width: 412px;
font: 87.5%/1.5em sans-serif !important;
margin-top:20px;
display: inline-block;
text-align:left !important;
}
.containerright {
height: 312px;
width: 412px;
font: 87.5%/1.5em sans-serif !important;
margin-top:20px;
display: inline-block;
text-align:left !important;
float: right
}
.container a{
text-decoration:none;
}
.container img{
bottom: 0;
display: block;
height: auto;
max-width: 100%;
}
.button {
background: #0084b4;
border-radius: 3px;
color: #fff;
display: inline-block;
font-weight: bold;
padding: 4px 8px;
position: absolute;
right: 20px;
top: 30px;
}
.button:hover {
background: #2D76B9;
color: #fff;
}
.dlbutton {
background: #0ead99;
border-radius: 3px;
color: #fff;
display: inline-block;
font-weight: bold;
padding: 4px 8px;
position: absolute;
right: 20px;
top: 30px;
}
.dlbutton:hover {
background: #0eb49f;
color: #fff;
}
.image-container {
border: 6px solid #fff;
box-shadow: 0 0 5px rgba(0, 0, 0, .3);
overflow: hidden;
position: relative;
width: 400px;
}
.image-container img {
-webkit-transition: all .4s;
-moz-transition: all .4s;
-ms-transition: all .4s;
-o-transition: all .4s;
transition: all .4s;
}
.image-container:hover img {
-webkit-transform: translateY(-45px);
-moz-transform: translateY(-45px);
-ms-transform: translateY(-45px);
-o-transform: translateY(-45px);
transform: translateY(-45px);
}
.image-container:hover figcaption {
opacity: 1;
-webkit-transform: translateY(0);
-moz-transform: translateY(0);
-ms-transform: translateY(0);
-o-transform: translateY(0);
transform: translateY(0);
-webkit-transition: -webkit-transform .4s, opacity .1s;
-moz-transition: -moz-transform .4s, opacity .1s;
-ms-transition: -ms-transform .4s, opacity .1s;
-o-transition: -o-transform .4s, opacity .1s;
transition: transform .4s, opacity .1s;
}
.image-container figcaption {
background: #283449;
bottom: 0;
color: #fff;
height: 50px;
left: 0;
opacity: 0;
padding: 20px;
position: absolute;
-webkit-transform: translateY(100%);
-moz-transform: translateY(100%);
-ms-transform: translateY(100%);
-o-transform: translateY(100%);
transform: translateY(100%);
-webkit-transition: -webkit-transform .4s, opacity .1s .3s;
-moz-transition: -moz-transform .4s, opacity .1s .3s;
-ms-transition: -ms-transform .4s, opacity .1s .3s;
-o-transition: -o-transform .4s, opacity .1s .3s;
transition: transform .4s, opacity .1s .3s;
width: 360px;
}
You just need to remove the margin-left from .image-container.
.image-container { margin-left:0; }
Change the size of containerright (from CSS) from 66% to 92%. This will align all the divs in center as well as wouldn't disturb page responsiveness.
Remove:
float: left;
float: right;
and they become centered.
.containerright {
height: 312px;
width: 412px;
font: 87.5%/1.5em sans-serif !important;
margin-top:20px;
display: inline-block;
text-align:left !important;
...
margin:0 auto; // add this
}
Do the same for other container too Which is in centre