I am trying to figure out a way to combine an animated hamburger menu in bootstrap 4 with a full screen menu overlay. Problem: when I set data-toggle="modal" on the button, I get the modal overlay but the animation of the collapsed hamburger menu ("X") in the background (i.e. underneath the overlay) becomes inactive.
On the other hand, when I replace the "modal" attribute with "collapse", the hamburger animation works fine but the overlay menu does not appear.
Is there a simple way to combine these two functions?
This is the CSS:
body {
padding-top: 5rem;
margin: 0;
background: url(../assets/original/test.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
background-repeat: no-repeat;
}
.base-layout {
padding: 3rem 1.5rem;
text-align: center;
}
/* Navbar responsive toggler + hamburger animation */
.navbar-toggler {
border: none;
background: transparent !important;
float: left !important;
margin-left: 15px;
margin-right: 0;
}
.navbar-toggler:focus {
outline: none;
background: transparent !important;
}
.navbar-toggler .icon-bar {
background-color: #fff;
transform: rotate(0deg) translate(0px, 0px);
transition: ease all .2s;
}
.navbar-toggler .icon-bar {
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
}
.navbar-toggler .icon-bar+.icon-bar {
margin-top: 4px;
}
/*.icon-bar:nth-child(2) {
width: 16px;
transition: ease all .2s;
}*/
.navbar-toggler:hover>.icon-bar:nth-child(2) {
width: 22px;
transition: ease all .2s;
}
.navbar-toggler:active>.icon-bar:nth-child(2) {
width: 22px;
transition: ease all .2s;
}
.navbar-toggler:not(.collapsed) .icon-bar:nth-child(1) {
transform: rotate(45deg) translate(5px, 4px);
transition: ease all .2s;
}
.navbar-toggler:not(.collapsed) .icon-bar:nth-child(2) {
opacity: 0;
transition: ease all .2s;
}
.navbar-toggler:not(.collapsed) .icon-bar:nth-child(3) {
transform: rotate(-45deg) translate(4px, -4px);
transition: ease all .2s;
}
/* Modal */
.modal-nav-content {
width: 100%;
height: auto;
}
.modal-nav-body {
margin-top: 100px;
}
.modal-nav-body ul {
list-style-type: none;
color: white;
margin: 0;
padding: 0;
width: 100%;
}
.modal-nav-body ul li {
text-align: center;
font-size: 130%;
padding: 8px;
text-transform: uppercase;
}
This is the HTML code:
<head>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<!-- Custom styles for this template -->
<link rel="stylesheet" type="text/css" href="css/custom.css">
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-md navbar-dark bg-transparent fixed-top">
<span class="navbar-brand" href="#"></span>
<!-- data-toggle="modal" :: COLLAPSE -->
<button type="button" class="navbar-toggler collapsed btn-open" data-toggle="modal" data-target="#nav-modal" aria-controls="nav-modal" aria-expanded="false" aria-label="Toggle navigation">
<span class="icon-bar top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
<span class="sr-only">Toggle navigation</span>
</button>
</nav>
<!-- Modal -->
<div class="modal fade" id="nav-modal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-nav-content">
<div class="modal-nav-body">
<ul class="wrap-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Nav menu item #1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Nav menu item #2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Nav menu item #3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Nav menu item #4</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<main role="main" class="container">
<div class="base-layout text-white text-left">
<h1>Title</h1>
<p class="lead">Lead text...</p>
</div>
</main>
<!-- Bootstrap core JavaScript placed at the end of the document so the pages load faster -->
<script src="https://bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</body>
I am trying to replicate this hover effect but I'm even sure where to start to be honest.
Here is my HTML code:
<div class="row">
<div class="col-sm-4 portfolio-item">
<a href="#" class="thumbnail">
<img src="img/portfolio/cabin.png">
</a>
</div>
<div class="col-sm-4 portfolio-item">
<a href="#" class="thumbnail">
<img src="img/portfolio/game.png">
</a>
</div>
<div class="col-sm-4 portfolio-item">
<a href="#" class="thumbnail">
<img src="img/portfolio/circus.png">
</a>
</div>
CSS: (all I have)
#portfolio .portfolio-item {
background-color: #18BC9C;
transition: all ease .5s;
-webkit-transition: all ease .5s;
}
#portfolio .portfolio-item:hover {
}
I don't even know where to begin. I think I need to fix something with the z-index and opacity but I don't know where to adjust it, and I'm also not sure where to put the transition effect. Everything I've tried has not worked so if someone could show me how to achieve that hover effect from a clean slate that would be greatly appreciated.
Hi this will get you started. First create an overlay opacity 0, then write a little jQuery so that on hover a class is applied opacity 1 with an rgba (rgb with opacity) and a css transition.
See the code for more, and run with this if you like I've separated the overlay from the image so you have control of them both:
$( document ).ready(function() {
$( '.portfolio-item' )
.mouseover(function() {
$( this ).find( '.overlay' ).addClass( 'show' );
})
.mouseout(function() {
$( this ).find( '.overlay' ).removeClass( 'show' );
});
});
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.col-sm-4 {
float: left;
width: 33%;
position: relative;
}
img {
width: 100%;
display: block;
}
.overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(145,0,0,0.5);
z-index: 2;
width: 100%;
height: auto;
opacity: 0;
-webkit-transition: .3s ease-in opacity;
-moz-transition: .3s ease-in opacity;
transition: .3s ease-in opacity;
}
.overlay.show {
opacity: 1;
}
.overlay.show:after {
content: 'x';
color: white;
position: absolute;
left: 50%;
margin-right: -50%;
top: 50%;
transform: translateY(-50%);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="row">
<div class="col-sm-4 portfolio-item">
<div class="overlay"></div>
<a href="#" class="thumbnail">
<img src="http://placehold.it/100x50">
</a>
</div>
<div class="col-sm-4 portfolio-item">
<div class="overlay"></div>
<a href="#" class="thumbnail">
<img src="http://placehold.it/100x50">
</a>
</div>
<div class="col-sm-4 portfolio-item">
<div class="overlay"></div>
<a href="#" class="thumbnail">
<img src="http://placehold.it/100x50">
</a>
</div>
You can use a pseudo element ::after to create an overlay. Just use opacity: 0; to hide it, and show it on hover: opacity: 0.6;. As transition you can use: transition: opacity ease .5s;.
This way, you can create an color overlay over every image (would not be possible with only using background on the parent element). To create the magnifying glass, you can either use a <span> inside the <a> tag, or the other pseudo element ::before.
.portfolio-item a {
position: relative;
}
.portfolio-item a::after {
position: absolute;
top: 0;
left: 0;
content: "";
width: 100%;
height: 100%;
background: #457647;
opacity: 0;
transition: opacity ease .5s;
}
.portfolio-item a:hover::after {
opacity: 0.6;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-sm-4 portfolio-item">
<a href="#" class="thumbnail">
<img src="//placehold.it/200x100/fff">
</a>
</div>
<div class="col-sm-4 portfolio-item">
<a href="#" class="thumbnail">
<img src="//placehold.it/200x100/fff">
</a>
</div>
<div class="col-sm-4 portfolio-item">
<a href="#" class="thumbnail">
<img src="//placehold.it/200x100/fff">
</a>
</div>
</div>
Of course you have to use vendor prefixes for older browsers. Also make sure that your markup is valid - a closing div tag was missing.
I'm looking for a plugin/code that can give some nice mouse hover animation over addThis share buttons, but still want to enjoy the 1-click tweet,like,etc. feature of addThis default buttons.
The one i have now is default, looks like,
What i want is something similar to the one used in arduino.cc blog, the default 1-click buttons are hidden by default and get visible only on mouse hover.
eg:-
How can i achieve this?
You can do this placing custom Images with actual sharing buttons together.
Keep all the sharing button width 0 by default and make them visible on hover by increasing width.
Also add CSS transition to expend the buttons smoothly.
Consider this example.
.sharing-buttons {
float: left;
margin: 5px;
}
.share-button {
float: right;
margin-left: 5px;
overflow: hidden;
transition: all 0.6s ease 0s;
white-space: nowrap;
width: 0;
}
.sharing-buttons:hover .share-button {
width: 100px;
}
<div id="wrapper">
<div class="sharing-buttons fb">
Custom Image
<div class="share-button">Button iframe</div>
</div>
<div class="sharing-buttons tw">
Custom Image
<div class="share-button">Button iframe</div>
</div>
</div>
Edit: Final addThis code & CSS
.addthis_toolbox a.at300b, .addthis_toolbox a.at300m {
padding: 5px;
width: auto;
}
.social-container {
float: left;
margin: 5px;
width:auto;
}
.social-content {
float: right;
margin-left: 5px;
overflow: hidden;
-moz-transition: max-width .3s ease-out;
-webkit-transition: max-width .3s ease-out;
-o-transition: max-width .3s ease-out;
transition: max-width .3s ease-out;
white-space: nowrap;
max-width: 0;
}
.social-container:hover .social-content {
-moz-transition: max-width .2s ease-in;
-webkit-transition: max-width .2s ease-in;
-o-transition: max-width .2s ease-in;
transition: max-width .2s ease-in;
max-width: 95px;
}
<div class="addthis_toolbox addthis_default_style ">
<!-- FACEBOOK -->
<div class="social-container">
<img src="<?php bloginfo('template_directory'); ?>/images/facebook.png" alt="" />
<div class="social-content">
<a class="addthis_button_facebook_like at300b" fb:like:layout="button_count"></a>
</div>
</div>
<!-- G+ -->
<div class="social-container">
<img src="<?php bloginfo('template_directory'); ?>/images/gplus.png" alt="" />
<div class="social-content">
<a class="addthis_button_google_plusone" g:plusone:size="large"></a>
</div>
</div>
<!-- TWITTER -->
<div class="social-container">
<img src="<?php bloginfo('template_directory'); ?>/images/twitter.png" alt="" />
<div class="social-content">
<a class="addthis_button_tweet at300b"></a>
</div>
</div>
</div>
So I have a website that looks like this:
(I censored it a little, it's super secret)
Now in full screen on PC this looks just fine but watch what happens when I shrink it down to Mobile Size:
I can no longer reach the bottom and see the three buttons. After experimenting it appears that the buttons shrink down to a very small size and then the bottom navbar overlaps.
<div class="categories-container">
<div class="container">
<div class="h1" style="color: #ffffff;text-align: center;">Or Click One of these Core Categories!</div>
<div class="btn-group btn-group-justified" role="group" aria-label="...">
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-success btn-bg" id="category-gameplay-btn"></button>
</div>
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-warning btn-bg" id="category-editor-btn"></button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-danger btn-bg" id="category-engine-btn"></button>
</div>
</div>
</div>
</div>
<div class="footer-container">
<div class="navbar navbar-default navbar-fixed-bottom">
<div class="container" style="text-align: center">
<span>Website made possible with the following tools</span>
<br>
<span>
jQuery | Bootstrap | glyphicons | <a href="https://pages.github.com/">Github Pages</a>
</span>
</div>
</div>
</div>
This should be the code you need. If you require more let me know.
EDIT
CSS Below:
body {
background-color: #0ba7ff;
}
.header-container .jumbotron {
background-color: #0ba7ff;
border-color: #ffffff;
border-style: solid;
color: #ffffff;
text-align: center;
}
#media (max-width: 767px) {
.jumbotron.jumbotronic {
padding-left: 20px;
padding-right: 20px;
}
}
.categories-container .btn.btn-bg {
height: 300px;
font-size: 60px;
white-space: normal;
}
#media (max-width: 767px) {
.categories-container .btn.btn-bg {
height: 150px;
font-size: 30px;
}
}
#media (max-width: 480px) {
.categories-container .btn.btn-bg {
height: 75px;
font-size: 22px;
}
}
#media (max-width: 360px) {
.categories-container .btn.btn-bg {
height: 35px;
font-size: 15px;
}
}
/* Base styles for the entire tooltip */
[data-tooltip]:before,
[data-tooltip]:after,
.tooltip:before,
.tooltip:after {
position: absolute;
visibility: hidden;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
opacity: 0;
-webkit-transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
-webkit-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
-moz-transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
-moz-transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
transform 0.2s cubic-bezier(0.71, 1.7, 0.77, 1.24);
-webkit-transform: translate3d(0, 0, 0);
-moz-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
pointer-events: none;
}
/* Show the entire tooltip on hover and focus */
[data-tooltip]:hover:before,
[data-tooltip]:hover:after,
.tooltip:hover:before,
.tooltip:hover:after{
visibility: visible;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=100);
opacity: 1;
}
/* Base styles for the tooltip's content area */
.tooltip:after,
[data-tooltip]:after {
z-index: 1000;
padding: 8px;
width: 160px;
background-color: #000;
background-color: hsla(0, 0%, 20%, 0.9);
color: #fff;
content: attr(data-tooltip);
font-size: 14px;
line-height: 1.2;
}
/* Base styles for the tooltip's directional arrow */
.tooltip:before,
[data-tooltip]:before {
z-index: 1001;
border: 6px solid transparent;
background: transparent;
content: "";
}
/* Horizontally align top/bottom tooltips */
[data-tooltip]:after,
.tooltip:after,
.tooltip-top:after {
margin-left: -80px;
}
[data-tooltip]:hover:before,
[data-tooltip]:hover:after,
[data-tooltip]:focus:before,
[data-tooltip]:focus:after,
.tooltip:hover:before,
.tooltip:hover:after,
.tooltip:focus:before,
.tooltip:focus:after,
.tooltip-top:hover:before,
.tooltip-top:hover:after,
.tooltip-top:focus:before,
.tooltip-top:focus:after {
-webkit-transform: translateY(-12px);
-moz-transform: translateY(-12px);
transform: translateY(-12px);
}
/* Bottom */
.tooltip-bottom:before,
.tooltip-bottom:after {
top: 100%;
bottom: auto;
left: 50%;
}
.tooltip-bottom:before {
margin-top: -12px;
margin-bottom: 0;
border-top-color: transparent;
border-bottom-color: #000;
border-bottom-color: hsla(0, 0%, 20%, 0.9);
}
.tooltip-bottom:hover:before,
.tooltip-bottom:hover:after,
.tooltip-bottom:focus:before,
.tooltip-bottom:focus:after {
-webkit-transform: translateY(12px);
-moz-transform: translateY(12px);
transform: translateY(12px);
}
Loaded after bootstrap.css
It appears you're using bootstrap. I don't know the coding of your css file but if you do happen to set a height for .categories it'd tend to overlap. Try give it a .row class and .col-sm-13 for the buttons to remain inline. Once it reaches the screen of a mobile device it won't overlap. Try. I hope this helps or gives you an idea :)
<div class="categories-container">
<div class="container">
<div class="h1" style="color: #ffffff;text-align: center;">Or Click One of these Core Categories!</div>
<div class="row">
<div class="btn-group btn-group-justified col-sm-12" role="group" aria-label="...">
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-success btn-bg" id="category-gameplay-btn"></button>
</div>
<div class="btn-group" role="group" style="padding-right: 10px">
<button type="button" class="btn btn-warning btn-bg" id="category-editor-btn"></button>
</div>
<div class="btn-group" role="group">
<button type="button" class="btn btn-danger btn-bg" id="category-engine-btn"></button>
</div>
</div>
</div> <!-- row-->
</div>
So here is the solution for anyone else looking after a fix for this:
There was none from what I experience, make your own:
This is necessary to add:
body {
height: 100%;
}
Here is the CSS for the div which holds the three buttons in question (so basically the last container in your HTML document before the footer):
.categories-container {
min-height: 100%;
margin-bottom: -30px; /* Negative half the height of the footer to leave space*/
position: relative;
}
Then I made this at the bottom of my index.html page:
<div id="wrap">
<div id="main"></div>
<div id="footer">
jQuery | Bootstrap |
glyphicons | <a href="https://pages.github.com/">Github Pages</a>
</div>
</div>
Here is the footer CSS:
#wrap #footer {
position: relative;
bottom: 0;
width: 100%;
height: 60px;
background: #f8f8f8;
text-align: center;
}
#wrap #footer a {
padding-top: 30px;
}
#wrap #main {
height: 60px;
clear: both;
}
I hope this was useful for some!
I have this code which works fine in Firefox and IE, but not in Chrome. What it does is, it starts a slide image animation, over existing image when the cursor is on it. Is there any part of the code that Chrome does not support?
<td width="214">
<div style="margin-left:19px; margin-top:-8px">
<div class="wrapper">
<img src="icon1.png">
<a href="http://www.somesite.com" target="_blank">
<img id="slide" src="slide_img.png" />
</a>
</div>
</div>
</td>
.wrapper{
position: relative;
overflow: hidden;
width: 197px;
height: 162px;
}
#slide{
position: absolute;
left: -197px;
width: 197px;
height: 162px;
background: transparent;
transition: 0.5s;
}
.wrapper:hover #slide {
transition: 0.3s;
left: 0;
}
The problem was in the first image in the wrapper. Try providing a bacground to the div rather than using the img tag
Fiddle
Modified html
<td width="214">
<div style="margin-left:19px; margin-top:-8px">
<div class="wrapper" >
<a href="http://www.biography.com/imported/images/Biography/Images/Profiles/K/Kaka-559558-1-402.jpg" target="_blank">
<img id="slide" src="http://3.bp.blogspot.com/-9qLJXsHoVag/T_rA4WlE-PI/AAAAAAAAB0I/I4gHxidRYEY/s320/kaka.jpg" />
</a>
</div>
</div>
</td>
and css
.wrapper{
position: relative;
overflow: hidden;
width: 197px;
height: 162px;
background:url('http://www.biography.com/imported/images/Biography/Images/Profiles/K/Kaka-559558-1-402.jpg')
}
You need to give Prefix for this
.cssname
{
transition: 0.5s;
-webkit-transition: 0.5s;
-moz-transition: 0.5s;
}