how would i add a transition on a div overlay - html

I would like to add a transition on the overlay but i can't work out which class it needs to be on to make it work. I'd like it to transition down from the top. Something along the lines of
-webkit-transform: translateY(-100%);
-ms-transform: translateY(-100%);
transform: translateY(-100%);
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
HTML
<ul class="about-image">
<li>
<div class="image"></div>
<div class="overlay"><div class="bt1">Dan Morris</div><div class="bt2">Multimedia Journalist</div></div>
</li>
</ul>
CSS
.image{
height: 252px;
width: 252px;
margin-left: auto;
margin-right: auto;
margin-top: 40px;
margin-bottom: 40px;
background-image: url(../images/danmorris_profile.png);
}
.overlay{
width:252px;
height:252px;
display:none;
position:absolute;
top:40px;
left:0px;
}
.overlay div {
position:relative;
display:inline-block;
top:40px;
margin: 40px 5px 0 0;
}
ul { list-style: none; width: 252px;
margin-left: auto;
margin-right: auto;
margin-bottom: 60px;
}
ul li {
position: relative;
display: inline-block;
width: 252px;
height: 252px;
}
li:hover .overlay {
display:block;
background-color:black;
opacity:0.75;
}
.bt1 {
background-color:orange;
width:50px;
height:50px;
}
.bt2 {
background-color:green;
width:50px;
height:50px;
}
Any help would be greatly appreciated. Thanks in advance

You need to apply the effect to the .overlay - Transition cannot be set to transform as it is not supported (Reference).
To get the effect you are after, try the following:
Remove your display: none; - this cannot be animated.
Style your .overlay completely but set top: -100%;, position: absolute;, and transition: top 0.3s ease-in-out;.
On hover, just change to top: 0;.
Finally, add overflow: hidden; to the li container.
ul {
list-style: none;
width: 252px;
margin: 40px auto 60px auto;
}
ul li {
position: relative;
display: inline-block;
width: 252px;
height: 252px;
overflow: hidden;
}
li:hover .overlay {
top: 0;
}
.overlay{
width:252px;
height:252px;
opacity: 0.75;
position:absolute;
background-color:black;
top:-100%;
transition: top 0.3s ease-in-out;
}
.overlay div {
position:relative;
display:inline-block;
top:40px;
margin: 40px 5px 0 0;
}
.bt1 {
background-color:orange;
width:50px;
height:50px;
}
.bt2 {
background-color:green;
width:50px;
height:50px;
}
<ul class="about-image">
<li>
<img src="http://placehold.it/252x252"></div>
<div class="overlay">
<div class="bt1">Dan Morris</div>
<div class="bt2">Multimedia Journalist</div>
</div>
</li>
</ul>
For convenience I have moved your .image to an element - but it will work with both. Also added some ease for smoothness.
Pen here

Related

Dropdown Menu with pure CSS and HTML

I have below CSS for a dropdown menu:
.dropdown {
position: relative;
display: inline-block;
}
.dropdown-content {
display: none;
position: absolute;
right: 0;
top: 30px;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
button, a {
border-bottom: 1px solid #e7e7e7;
border-radius: unset;
text-align: left;
display: inline-block;
width: 100%!important;
.icon {
margin-right: 15px;
top: 0.13em;
}
&:hover {
background-color: #e7e7e7 !important;
}
&:active {
background-color: #c7c7c7 !important;
}
}
}
.dropdown:hover .dropdown-content {
display: block;
}
And below markup:
<div class="dropdown">
<button class="material-icon-button">
<i class="icon icon-more_vert"></i>
</button>
<div class="dropdown-content" style="width: 295px;">
<button class="material-button">
<i class="icon icon-undo"></i>
<span>Button 1</span>
</button>
<button class="material-button">
<i class="icon icon-add_alert"></i>
Button 2
</button>
</div>
</div>
This works fine and shows menu on mouseover.
What I am trying to achieve is that, instead of mouseover, the dropdown is shown when the user actually clicks the button.
I have tried:
.dropdown:active .dropdown-content {
display: block;
}
But It doesn't seem to work, it show the menu on click but hides immediately.
I was wondering if this could be done without JavaScript and with pure css? if so, can someone please guide on this.
Thanks
There is a way to handle clicks with pure CSS.
It's not the best way (because that's not what CSS is made for) but it should work. Basically you'll have to use a checkbox with a label and style according to the state of the checkbox.
Here is an example: https://css-tricks.com/the-checkbox-hack/
try like below, hope it helps, comment if query
.c {
display: flex;
align-items: center;
justify-content: center;
height:100%;
width:100%;
}
.dd {
z-index:1;
position:relative;
display: inline-block;
}
.dd-a {
padding:10px;
background:white;
position:relative;
box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.75);
transition-duration: 0.2s;
-webkit-transition-duration: 0.2s;
}
.dd input:after {
content:"";
width:100%;
height:2px;
position:absolute;
display:block;
background:#C63D0F;
bottom:0;
left:0;
transform: scaleX(0);
transform-origin: bottom left;
transition-duration: 0.2s;
-webkit-transform: scaleX(0);
-webkit-transform-origin: bottom left;
-webkit-transition-duration: 0.2s;
}
.dd input {
top:0;
opacity:0;
display:block;
padding:0;
margin:0;
border:0;
position:absolute;
height:100%;
width:100%;
}
.dd input:hover {
cursor:pointer;
}
.dd input:hover ~ .dd-a {
box-shadow: 0px 0px 15px 0px rgba(0,0,0,0.75);
}
.dd input:checked:after {
transform: scaleX(1);
-webkit-transform: scaleX(1);
}
.dd input:checked ~ .dd-c {
transform: scaleY(1);
-webkit-transform: scaleY(1);
}
.dd-a span {
color:#C63D0F;
}
.dd-c{
display:block;
position: absolute;
background:white;
height:auto;
transform: scaleY(0);
transform-origin: top left;
width: 100%;
}
.dd-c ul {
margin:0;
padding:0;
list-style-type: none;
}
.dd-c li {
margin-botom:5px;
word-break: keep-all;
white-space:nowrap;
display:block;
position:relative;
}
a {
display:block;
position:relative;
text-decoration: none;
padding:5px;
background:white;
color:#C63D0F;
}
a:before {
z-index:0;
content:"";
position:absolute;
display:block;
height:100%;
width:100%;
transform-origin:top left;
background:#C63D0F;
top:0;
left:0;
transform: scaleX(0);
-webkit-transform: scaleX(0);
}
a span {
display:block;
position:relative;
}
a:hover:before {
transform:scaleX(1);
-webkit-transform:scaleX(1);
}
a:hover span {
color:white;
}
<div class="c">
<div class="dd">
<div class="dd-a"><span>Dropdown menu</span></div>
<input type="checkbox">
<div class="dd-c">
<ul>
<li><span>Link</span></li>
<li><span>Link</span></li>
<li><span>Link</span></li>
</ul>
</div>
</div>
</div>

Center carousel on responsive

My carousel has a bad alignament on small screens, but on laptop/desktop its fine. Ill attached for you a screenshot and my css code.
Thanks a lot.
.MultiCarousel { margin-right:15px; margin-left: 15px;float: left; overflow: hidden; padding: 5px; width: 100%; position:relative; }
.MultiCarousel .MultiCarousel-inner { transition: 1s ease all; float: left; }
.MultiCarousel .MultiCarousel-inner .item { float: left;}
.MultiCarousel .MultiCarousel-inner .item > div { text-align: center; padding:10px; margin:10px; background:#f1f1f1; color:#666;}
.MultiCarousel .leftLst, .MultiCarousel .rightLst { position:absolute; border-radius:50%;top:20% ; }
.MultiCarousel .leftLst { left:0; }
.MultiCarousel .rightLst { right:0; }
.MultiCarousel .leftLst.over, .MultiCarousel .rightLst.over { pointer-events: none; background:#ccc; }
Do not use left: and right: rather take a look at this
https://www.w3schools.com/css/css_align.asp
all you need to do on the carousel is margin: 0 auto;

CSS: transform 1 pixel shift on Chrome

In the actual version of the Chrome browser there is a little issue when transition of this code finishes: 1 pixel shift of the line height on the bottom (on hover of the links).
Also, I've noticed that in code snippets of jsfiddle and here it may not be visible, but on the CodePen and on my website this is what happens. Checked on Firefox - everything is fine and on every web site.
Here is snippet of Stack Overflow and CodePen:
https://codepen.io/Maxim222/pen/OQWWEB
body{
background:#111;
}
ul{
margin:0;
padding:0;
list-style:none;
}
ul li{
float:left;
position:relative;
}
li a{
padding:10px;
color:#fff;
text-decoration:none;
}
li a:before{
content:'';
-webkit-transform: scaleX(0);
transform: scaleX(0);
background-color: #fb0;
bottom: 0px;
height: 15px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
width: 100%;
transition:all 1s;
}
li a:hover:before{
bottom:0;
transform: scaleX(1);
-webkit-transform: scaleX(1);
}
<div>
<ul>
<li>Hello</li>
<li>Worldsdfsdf</li>
</ul>
</div>
From what I know, it's not your fault, it's a "glitch" with the scaleX param. If you use 0.99 as a value instead of 1, it should work fine.
body {
background: #111;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
ul li {
float: left;
position: relative;
}
ul li a {
padding: 10px;
color: #fff;
text-decoration: none;
}
ul li a:before {
content: '';
-webkit-transform: scaleX(0);
transform: scaleX(0);
background-color: #fb0;
bottom: 0px;
height: 15px;
left: 0;
margin: 0;
padding: 0;
position: absolute;
width: 100%;
transition: all 1s;
}
ul li a:hover:before {
bottom: 0;
transform: scaleX(0.99);
-webkit-transform: scaleX(0.99);
}
<div>
<ul>
<li>Hello</li>
<li>Worldsdfsdf</li>
</ul>
</div>

Fixed Width List Items Extend Full Length of Page

I have a navigation menu that takes up to 250px in width of the page's left side and 100% in height. I added a 1. Fixed Top Title List Item at the top of the navigation menu, as well as a 2. Fixed Footer List Item at the very bottom of the navigation menu. My idea is to keep both items fixed, and both items have to also disappear when the browser width is a certain size. but I have a big problem:
Problem 1: When I add the fixed width to .topfilter and .bottomfilter, the list items now extend the full width of the
entire page instead of the navigation menu.
Problem 2: Now when I resize the browser the fixed width items
don't disappear
Bonus: I also don't know how to add a padding to the .topfilter and .bottomfilter so that they don't cover up the text before it.
Padding-Top and Padding-Bottom don't work.
Fixed Width Items: https://jsfiddle.net/4fqapznu/1/
.topfilter {border-bottom:solid #333 2px; width:100%; height:40px; position:fixed; display:block; text-align:left; background-color:blue; -moz-box-sizing: border-box;
box-sizing: border-box;}
.bottomfilter {border-top: solid #333 2px; width:100%; height:50px; position:fixed; display:block; text-align:left; background-color:red; -moz-box-sizing: border-box; box-sizing: border-box; bottom:0;}
HTML:
<!-- Sidebar -->
<div id="sidebar-wrapper">
<ul class="sidebar-nav">
<li class="topfilter">
<a class="filtertitle">Title</a>
</li>
<li>
<a href="#/content">
Content
</a>
</li>
<li>
<a href="#/topics">
Topics
</a>
</li>
<li>
<a href="#">
Groups
</a>
</li>
<li>
<a href="#">
Premium
</a>
</li>
<li>
Dashboard
</li>
<li>
Shortcuts
</li>
<li>
Overview
</li>
<li>
Events
</li>
<li>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
<li class="bottomfilter">
<a class="filtertitle">Footer</a>
</li>
</ul>
</div>
<!-- /#sidebar-wrapper -->
<div class="content" style="min-height:90%; background:white;" >
</div>
<div class="push"></div>
<footer class="footer">
</footer>
CSS:
a {outline:none !important;}
html,
body,
.wrap {
height: 100%;
}
.wrap {
box-sizing: border-box;
}
form {
height: 100%
}
.wrap {
min-height: 100%;
height: auto !important;
height: 100%;
margin-bottom: -60px;
/* for sticky footer to not go below page */
/* for sticky header to not overlap content */
}
.push,
.footer {
height: 60px;
}
.footer {
background-color: #ebebeb;
height: 60px;
width: 100%;
position: fixed;
bottom: 0;
}
.content {
position: absolute;
width: 100%;
top: 120px;
background-color: yellow;
z-index: 0;
}
#sidebar-wrapper {
z-index: 1000;
position: fixed;
left: 142px;
top: 0px;
margin-bottom: 60px;
width: 0;
height: 100%;
margin-left: -142px;
overflow-y: auto; overflow-x: hidden;
background: #eee;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.topfilter {border-bottom:solid #333 2px; width:100%; height:40px; position:fixed; display:block; text-align:left; background-color:blue; -moz-box-sizing: border-box:
box-sizing: border-box:}
.filtertitle { position:relative; display:inline-block; color:#000; width:100%; }
.topfilter {border-bottom:solid #333 2px; width:100%; height:40px; position:fixed; display:block; text-align:left; background-color:blue; -moz-box-sizing: border-box:
box-sizing: border-box:}
.filtertitle { position:relative; display:inline-block; color:#000; width:100%; }
.topfilter {border-bottom:solid #333 2px; width:100%; height:40px; position:fixed; display:block; text-align:left; background-color:blue; -moz-box-sizing: border-box;
box-sizing: border-box;}
.bottomfilter {border-top: solid #333 2px; width:100%; height:50px; position:fixed; display:block; text-align:left; background-color:red; -moz-box-sizing: border-box; box-sizing: border-box; bottom:0;}
#wrapper.toggled #sidebar-wrapper {
width: 200px;
}
#page-content-wrapper {
width: 100%;
position: absolute;
padding: 15px;
}
#wrapper.toggled #page-content-wrapper {
position: absolute;
margin-right: -200px;
}
/* Sidebar Styles */
.sidebar-nav {
position: absolute;
top: 0px;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
}
.sidebar-nav li {
text-indent: 20px;
line-height: 40px;
}
.sidebar-nav li a {
display: block;
text-decoration: none;
color: #999999;
}
.sidebar-nav li a:hover {
text-decoration: none;
color: #333;
background: rgba(255, 255, 255, 0.6);
}
.sidebar-nav li a:active,
.sidebar-nav li a:focus {
text-decoration: none;
}
.sidebar-nav > .sidebar-brand {
height: 65px;
font-size: 18px;
line-height: 60px;
}
.sidebar-nav > .sidebar-brand a {
color: #999999;
}
.sidebar-nav > .sidebar-brand a:hover {
color: #fff;
background: none;
}
#media screen and (min-width:768px) {
#wrapper {
padding-left: 300px;
}
#wrapper.toggled {
padding-left: 0;
}
#wrapper.toggled #sidebar-wrapper {
width: 0;
}
#page-content-wrapper {
padding: 20px;
position: relative;
}
#wrapper.toggled #page-content-wrapper {
position: relative;
margin-right: 0;
}
}
#media screen and (max-width:1526px) {
.content,
.footer {
width: 82%;
right: 0;
}
.header {width:82%;}
#sidebar-wrapper {
width: 18%;
}
}
#media screen and (max-width:1059px) {
.content,
.footer {
width: 80%;
right: 0;
}
.header {width:80%;}
#sidebar-wrapper {
width: 20%;
}
}
#media screen and (min-width:1527px) {
.content,
.footer {
width: 85%;
right: 0;
}
.header {width:85%;}
#sidebar-wrapper {
width: 15%;
}
}
#media screen and (max-width:991px) {
.content,
.footer {
width: 100%;
right: 0;
}
#sidebar-wrapper {
width:0;
}
The Answer was very simple: https://jsfiddle.net/4fqapznu/3/
All I had to do was:
Add min-width:100%, and replace width:100% with width:inherit on the parent container: .sidebar-nav
Then add width:inherit on the 2 children with position fixed items:
.topfilter and .bottomfilter
Here's the code that fixed it for me:
.sidebar-nav {
width:inherit; min-width:100%;
}
.topfilter {width:inherit; position:fixed;}
.bottomfilter { width:inherit; position:fixed;
Note: Now I have another problem with the fixed items overlapping the scrollbar, but I will ask that question on another thread unless someone has a quick answer on how to fix it.

How to solve css issue to display image caption?

I want to display some image with caption.By default its showing image only but I want to display image with caption by default.I am giving my css and html code below :
<style type="text/css">
.caption-style-1{
list-style-type: none;
margin: 0px;
padding: 0px;
}
.caption-style-1 li{
float: left;
padding: 0px;
position: relative;
overflow: hidden;
margin-right:5px;
}
.caption-style-1 li:hover .caption{
opacity: 1;
}
.caption-style-1 .hover-effect{
margin: 0px;
padding: 0px;
float: left;
width:220px;
height:150px;
//background-color:#999;
margin-bottom:5px;
}
.hover-effect img{
margin: 0px;
padding: 0px;
float: left;
z-index: 4;
}
.hover-effect h1
{
font-size:20px;
border:solid 1px red;
}
.hover-effect p
{
font-size:13px;
margin:0;
padding:0;
}
.caption-style-1 .caption{
cursor: pointer;
position: absolute;
opacity: 0;
-webkit-transition:all 0.45s ease-in-out;
-moz-transition:all 0.45s ease-in-out;
-o-transition:all 0.45s ease-in-out;
-ms-transition:all 0.45s ease-in-out;
transition:all 0.45s ease-in-out;
}
.caption-style-1 .blur{
//background-color: rgba(0,0,0,0.65);
height: 150px;
width: 220px;
z-index: 5;
position: absolute;
}
.caption-style-1 .caption-text h1{
text-transform: uppercase;
font-size: 10px;
}
.caption-style-1 .caption-text .blur{
z-index: 10;
color: #fff;
position: absolute;
width: 220px;
height: 150px;
text-align: center;
background-color: rgba(0,0,0,0.65);
}
/** Nav Menu */
ul.nav-menu{
padding: 0px;
margin: 0px;
list-style-type: none;
width: 490px;
margin: 60px auto;
}
ul.nav-menu li{
display: inline;
margin-right: 10px;
padding:10px;
border: 1px solid #ddd;
}
ul.nav-menu li a{
color: #eee;
text-decoration: none;
text-transform: uppercase;
}
ul.nav-menu li a:hover, ul.nav-menu li a.active{
color: #2c3e50;
}
.opacity
{
opacity:0.2;
filter:alpha(opacity=20); /* For IE8 and earlier */
}
</style>
And my html code's are given below :
<ul class="caption-style-1">
<li>
<div class="hover-effect">
<div class="opacity"><img src="img/chaps_1x.jpg" width="220px" height="150px" alt=""></div>
<h1>Amazing Caption</h1>
<p>Whatever It Is - Always Awesome</p>
</div>
<div class="caption">
<div class="blur"></div>
<div class="caption-text">
<img src="img/chaps_1x.jpg" width="220px" height="150px" alt="">
</div>
</div>
</li>
</ul>
Any Idea?
Your HTML code is not written in well manner. If you using HTML5 then you may use HTML5 tags like figcaption with figure. The Caption tag is not showing in your style because they are behind the image.
So here is the way to move to front using z-index property.
.hover-effect h1
{
font-size:20px;
border:solid 1px red;
position:fixed;
z-index:999;
}
.hover-effect p
{
font-size:13px;
margin:0;
padding:0;
position:fixed;
z-index:999;
}
Here is the Demo. http://jsbin.com/yegiyico/1/