My elements in a menu seem to have no width? - css

see this codepen for a demo
EDIT of course, hard coding a width for an element is no solution. It should be just the size of the actual title.
HTML
<br/>
<nav class="navigation">
<div class="navfake"></div>
<div class="singleelement">
<div class="container">
<div class="title">Test title 2</div>
<div class="titlepicture">some picture</div>
</div>
</div>
<div class="singleelement">
<div class="container">
<div class="title">Test title newsfeed super long 1</div>
<div class="titlepicture">some picture</div>
</div>
</div>
</nav>
css
/** the newsfeed and footer */
nav {
width: 100%;
height: 20px;
position: relative;
}
.navfake {
width: 100%;
height: 100%;
background: green;
z-index: 10;
position: relative;
}
.singleelement {
display: inline-block;
height: 60px;
text-align: center;
}
.container {
position: absolute;
top: 0px;
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
height: 200px;
}
.titlepicture {
position: absolute;
width: 100%;
background-color: red;
z-index: 10;
height: 100px;
overflow: hidden;
}
.container:hover {
top: -80px;
}
.container:hover .titlepicture {
height: 100px;
z-index: 10;
}
.title {
z-index: 555;
position: relative;
height: 20px;
width: 100%;
}
.footer {
position: relative;
z-index: 1000;
background-color: white;
}

The trick was to replace position absolute with position relative
HTML
<nav class="navigation">
<div class="navfake"></div>
<div class="singleelement">
<div class="container">
<div class="title">Test title 2</div>
<div class="titlepicture">some picture</div>
</div>
</div>
<div class="singleelement">
<div class="container">
<div class="title">Test title newsfeed super long 1</div>
<div class="titlepicture">some picture</div>
</div>
</div>
</nav>
<div class="footer">some text blablablablablablabla
<br/>some text blablablablablablabla
<br/>some text
<br/>some text
<br/>some text
<br/>some text
<br/>some text
<br/>xxx
</div>
CSS
/** the newsfeed and footer */
nav {
width: 100%;
height: 20px;
}
.navfake {
width: 100%;
height: 100%;
background: green;
z-index: 10;
position: relative;
}
.singleelement {
display: inline-block;
height: 60px;
text-align: center;
position: relative;
}
.container {
top: -20px;
position: relative; /**changed*/
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
height: 200px;
}
.titlepicture {
position: absolute;
background-color: red;
z-index: 10;
height: 100px;
overflow: hidden;
}
.container:hover {
top: -80px;
}
.container:hover .titlepicture {
height: 100px;
z-index: 10;
}
.title {
z-index: 555;
position: relative;
height: 20px;
width: 100%;
}
.footer {
position: relative;
z-index: 1000;
background-color: white;
}

On .singleelement add some sort of width to it. For example 64px and it will work.
Fiddle: http://jsfiddle.net/7WZk5/

Perhaps this is what you're looking for: http://codepen.io/aytimothy/pen/mlkAh
Have you tried adding the "width:" CSS into your "container" Class?
.container {
position: absolute;
top: 0px;
-webkit-transition: all .8s ease;
-moz-transition: all .8s ease;
-ms-transition: all .8s ease;
-o-transition: all .8s ease;
transition: all .8s ease;
height: 200px;
width: 50%;
}
Well, 50% since you have two elements. If you want to have different widths for each of them, you could always put the width as a STYLE attribute for each element.

Related

Hover div visible outside element

How can I keep the black box on hover, to be only visible sliding out inside the box-1 div?
.description {
position: absolute;
background: black;
width: 100%;
height: 200px;
bottom: -100%;
visibility: hidden;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;}
.box-1:hover .description
{
visibility: visible;
bottom: 0;
}
.grid-item {
background: rgba(6, 108, 121, 0.322);
position: relative;
border: 3px solid white;
width: 100%;
height: 200px;
display: grid;
cursor: pointer;
place-items: center;
}
<div class="grid-item box-1">
<h2 class="consulting">Test</h2>
<div class="description"><p>Description</p>
</div>
You can add overflow: hidden; to your parent
.description {
position: absolute;
background: black;
width: 100%;
height: 200px;
bottom: -100%;
visibility: hidden;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;
}
.box-1:hover .description {
visibility: visible;
bottom: 0;
}
.grid-item {
background: rgba(6, 108, 121, 0.322);
position: relative;
border: 3px solid white;
width: 100%;
height: 200px;
display: grid;
cursor: pointer;
place-items: center;
overflow: hidden;
}
<div class="grid-item box-1">
<h2 class="consulting">Test</h2>
<div class="description">
<p>Description</p>
</div>
Add overflow: hidden; to the class grid-item
This will make the black box appear to slide from inside.
.description {
position: absolute;
background: black;
width: 100%;
height: 200px;
bottom: -100%;
visibility: hidden;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-webkit-transition: all 0.3s ease-in-out;}
.box-1:hover .description
{
visibility: visible;
bottom: 0;
}
.grid-item {
background: rgba(6, 108, 121, 0.322);
position: relative;
border: 3px solid white;
width: 100%;
height: 200px;
display: grid;
cursor: pointer;
place-items: center;
overflow: hidden;
}
<div class="grid-item box-1">
<h2 class="consulting">Test</h2>
<div class="description"><p>Description</p>
</div>

Hover feature and Link shifted

I am new to coding, and I am making a home page. I was trying to get the black and white hover feature on the images of my home pages. However, when I hover my mouse over the image, it does not work. It is only until you hover to the left of the image that the image will turn from color to BW. Any ideas on how to fix this? Any help is greatly appreciated!
Here is my code:
#font-face {
font-family: "p22-underground";
src: qzo1okq;
}
.container {
position: absolute;
padding-bottom: 0px;
margin-top: -125px;
margin-right: -70px;
float: left;
}
.Marlon {
position: absolute;
margin-top: -275px;
margin-left: 15px;
}
/*B&W*/
.blue {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.blue:hover {
-webkit-filter: grayscale(100%);
}
.blue {
position: relative;
background-position: left top;
margin-top: 120px;
margin-left: -250px;
max-width:100%;
height:auto;
text-align: center;
}
/*B&W*/
.Tammy {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.Tammy:hover {
-webkit-filter: grayscale(100%);
display: block;
}
.Tammy {
position: relative;
background-position: left top;
margin-top: -5px;
margin-left: -250px;
max-width:100%;
height:auto;
text-align: center;
}
/*B&W*/
.Tacos {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.Tacos:hover {
-webkit-filter: grayscale(100%);
}
.Tacos {
position: relative;
background-position: center;
margin-top: -623px;
margin-left: 100px;
max-width:100%;
text-align: center;
}
/*B&W*/
.Glasses {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.Glasses:hover {
-webkit-filter: grayscale(100%);
}
.Glasses {
position: relative;
background-position: center;
margin-top: -5px;
margin-left: 100px;
max-width:100%;
height:auto;
text-align: center;
}
/*B&W*/
.Door {
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.Door:hover {
-webkit-filter: grayscale(100%);
}
.Door{
position: relative;
background-position: right top;
margin-top: -623px;
Margin-left:700px;
max-width:100%;
height:auto;
text-align: center;
}
.Social {
position: relative;
text-align: center;
inline: block;
padding-bottom: 0px;
top:-25px;
bottom: 0px;
margin:auto;
}
body {
background-image: url("http://ac.aup.edu/~a94241/background.jpeg");
}
ul {
list-style-type: none;
height: 50px;
margin: 150;
padding: 80;
overflow: hidden;
margin-top: 200px;
background-color: black;
font-family: "p22-underground";
font-weight: "500";
font-size: 150%;
}
li {
float: none;
color: "#fcf8de";
position: relative;
display: inline-block;
bottom: 12px;
margin-left: 10px;
margin-right: 10px;
}
li a {
display: block;
color: "#fcf8de";
text-align: center;
padding: 14px 16px;
margin-left: 5px;
}
footer {
height:10px;
padding: 20px;
margin-top:100px;
text-align:left;
vertical-align:middle;
padding-top: 14px;
background-color: black;
font-family: "p22-underground";
font-weight: "300";
position:static;
}
<!DOCTYPE html>
<html>
<head>
<script src="https://use.typekit.net/qzo1okq.js"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
</head>
<body>
<div class="container">
<a href="http://ac.aup.edu/~a94241/Marlon Coding.html">
<img src="http://ac.aup.edu/~a94241/cactus.png" alt="Cactus Vector" width="100" height="90">
</a>
</div>
<div class="Marlon">
<a href="http://ac.aup.edu/~a94241/Marlon Coding.html">
<img src="http://ac.aup.edu/~a94241/Marlon Vector.png" alt="Marlon Vector" width="450" height="550">
</a>
</div>
<ul>
<center>
<h1 style="font-p22-underground-sc, sans-serif;font-style:normal; font-weight:500; font-size:80% "</h1>
<li>PHILOSOPHIE</li>
<li>MENU</li>
<li>NOUS TROUVER</li>
<li>AVIS</li>
<li>CONTACT
</li>
</ul>
</center>
<div class="opacity">
<div class="blue">
<a href="http://ac.aup.edu/~a94241/Philosophie.html">
<img src="http://ac.aup.edu/~a94241/blue car.png" alt="BlueCar" width="300" height="310">
</a>
</div>
<div class="Tammy">
<a href="http://ac.aup.edu/~a94241/Avis.html">
<img src="http://ac.aup.edu/~a94241/tammy Lunch.png" alt="TammyLunch" width="300" height="310">
</a>
</div>
<div class="Tacos">
<a href="http://ac.aup.edu/~a94241/Contact.html">
<img src="http://ac.aup.edu/~a94241/tacos.png" alt="Tacos" width="300" height="310">
</a>
</div>
<div class="Glasses">
<a href="http://ac.aup.edu/~a94241/Menu.html">
<img src="http://ac.aup.edu/~a94241/Glasses.png" alt="Glasses" width="300" height="310">
</a>
</div>
<div class="Door">
<a href="http://ac.aup.edu/~a94241/Nous Trouver.html">
<img src="http://ac.aup.edu/~a94241/door.png" alt="Door" width="300" height="620">
</a>
</div>
</div>
<footer>
<p1><font color="#fcf8de">CALL: 01 40 60 12 12</font></p1>
<div class="Social">
<a href="https://www.facebook.com/restaurantmarlon">
<img src="http://ac.aup.edu/~a94241/facebook.png" alt="Facebook Vector" width="20" height="25">
</a>
<a href="https://www.instagram.com/restaurantmarlon/">
<img src="http://ac.aup.edu/~a94241/instragram.png" alt="Instargram Vector" width="20" height="25">
</a>
</div>
</footer>
</body>
</html>

Caption in Safari is not centered vertically

So this issue has been bugging me for quite a while. I have this div container that centers an overflow image to the center.
However in Safari, the icon inside the div is not positioned in the center. Instead it is at the top. It works fine in other browsers though. Only Safari has this bug.
I attached a fiddle below. Appreciate any help! :)
JSfiddle demo
var $container = $('#page');
$container.masonry({
columnWidth: '.grid-sizer',
itemSelector: '.item',
percentPosition: true,
gutter: 10
});
#page .item {
width: calc(16.66% - 10px);
display: inline-block;
height: 0;
float: left;
padding-bottom: 16.66%;
overflow: hidden;
background-color: salmon;
margin: 5px;
position: relative;
}
#page .item.s1 {
width: calc(50% - 10px);
padding-bottom: 50%;
overflow: hidden;
background-color: navy;
}
.item > a {
/* position: relative; */
display: block;
overflow: hidden;
color: white;
}
.item:hover .grid-image:after {
background: rgba(0, 0, 0, .7);
}
.item:hover .grid-image > img {
-webkit-transform: scale(1.1);
-moz-transform: scale(1.1);
-ms-transform: scale(1.1);
-o-transform: scale(1.1);
transform: scale(1.1);
}
.item:hover .item-caption {
opacity: 1;
z-index: 3;
visibility: visible;
}
.item-caption,
.grid-image > img,
.grid-image:after {
-webkit-transition: all 0.3s ease-in-out 0s;
-moz-transition: all 0.3s ease-in-out 0s;
-ms-transition: all 0.3s ease-in-out 0s;
-o-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
.item-caption {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(29, 106, 154, 0.72);
color: #fff;
visibility: hidden;
text-align: center;
opacity: 0;
display: table;
height: 100%;
width: 100%;
}
.item-caption > div {
display: table-cell;
height: 100%;
vertical-align: middle;
}
.grid-image {
position: relative;
overflow: hidden;
}
.grid-image img {
display: block;
overflow: hidden;
}
.grid-image:after {
position: absolute;
display: block;
content: "";
height: 100%;
width: 100%;
top: 0;
left: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/masonry/3.3.2/masonry.pkgd.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="container-fluid">
<div id="page">
<!-- GRID ITEM -->
<div class="item s1">
<a href="#">
<div class="grid-image">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/4/4e/Pleiades_large.jpg/1024px-Pleiades_large.jpg">
</div>
<div class="item-caption">
<div>
<h5>I want this to be center</h5>
</div>
</div>
</a>
</div>
<!-- /GRID ITEM -->
</div>
</div>
</body>
</html>

Sidebar transition using AngularJS using scope.apply not working

I have 2 sections of a page
1. Sidebar menu
2. Page content
When I click a button on the page content the slide bar menu should slide out. I am trying to achieve this using ngClass of Angular JS.
Here is my CSS first:
*,
*:after,
*::before {
-moz-box-sizing: border-box;
box-sizing: border-box;
}
html,body,
.st-container,
.st-pusher,
.st-content {
height:100%;
}
.st-content {
overflow-y:scroll;
}
.st-content,
.st-content-inner {
position:relative;
}
.st-container {
position: relative;
overflow: hidden;
}
.st-pusher {
position: relative;
left: 0;
z-index: 99;
height: 100%;
-webkit-transition: -webkit-transform 0.5s;
transition: transform 0.5s;
}
.st-pusher {
padding-left: 250px;
}
.st-pusher::after {
position: absolute;
top: 0;
right: 0;
width: 0;
height: 0;
background: rgba(0,0,0,0.2);
content: '';
opacity: 0;
-webkit-transition: opacity 0.5s, width 0.1s 0.5s, height 0.1s 0.5s;
transition: opacity 0.5s, width 0.1s 0.5s, height 0.1s 0.5s;
}
.st-menu-open .st-pusher::after {
width: 100%;
height: 100%;
opacity: 1;
-webkit-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.st-menu {
position: absolute;
top: 0;
left: 0;
z-index: 100;
visibility: visible;
width: 250px;
height: 100%;
background: #333300;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
.st-pusher-expand {
padding-left: 100px;
}
.st-menu-collapse {
position: absolute;
top: 0;
left: 0;
z-index: 100;
visibility: visible;
width: 50px;
height: 100%;
background: #333300;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
Here is my index.html:
<div class="st-container"> <!-- The whole screen -->
<div class="st-pusher" ng-class="myVar">
<nav class="st-menu" ng-class="myVar1"></nav> <!-- The navigation menu -->
<div class="st-content">
<div class="st-content-inner">
<div class="container" ng-view="">
</div>
</div>
</div>
</div>
</div>
Here is the controller code:
$scope.boolChangeClass = false;
$scope.click = function() {
if (!$scope.boolChangeClass) {
$scope.myVar = "st-pusher-expand";
$scope.myVar1 = "st-menu-collapse";
} else {
$scope.myVar = "st-pusher";
$scope.myVar1 = "st-menu";
}
$scope.boolChangeClass = !$scope.boolChangeClass;
setTimeout(function() {
$scope.$apply();
});
};
But the code is not working. I took a look at this example and it works if I try it out. But what I need is the right side content to resize to the full size of the container when the sidebar disappears.
Different transitions with AngularJS

transition animation does not work

Can someone please tell me what am I doing wrong here about transition? Because transition animation does not work at all, neither in chrome nor in opera browser.
Thank you.
<!doctype html>
<html lang="en">
<head>
<title>ttt</title>
<style type="text/css">
body {font: 13px sans-serif; }
#montage-wrap {width: 820px; height: 200px; }
.montage-block {width: 200px; height: 200px; float: left; display: block; overflow: hidden; position: relative;}
#block1 { width: 200px; height: 200px; position: absolute; display: block;
background: url("square.png");
-webkit-transition: top .3s; }
.montage-block:hover #block1 { top: -180px; }
.thumb_content { }
</style>
</head>
<body>
<div id="montage-wrao">
<div class="montage-block">
<span id="block1"></span>
<div class="thumb_vontent">
<h1>title</h1>
<p>subtitle</p>
</div>
</div>
</div> <!-- montage wrap -->
</body>
</html>
please try to at following css.
I can't see in your css transition for other browsers without webkit.
http://jsfiddle.net/8jQbN/
CSS:
-webkit-transition: all 3s ease; /* Firefox */
-moz-transition: all 3s ease; /* WebKit */
-o-transition: all 3s ease; /* Opera */
transition: all 3s ease; /* Standard */
}
Add top:0; for #block1 in css since you want to animate "top" element.You can change the value if you want to. The animation will works.
body {
font: 13px sans-serif;
}
#montage-wrap {
width: 820px;
height: 200px;
}
.montage-block {
width: 200px;
height: 200px;
float: left;
display: block;
overflow: hidden;
position: relative;
}
#block1 {
width: 200px;
height: 200px;
position: absolute;
display: block;
background:red;
top:0;
-webkit-transition: top 1s ease-in-out;
-moz-transition: top 1s ease-in-out;
-o-transition: top 1s ease-in-out;
transition: top 1s ease-in-out;
}
.montage-block:hover #block1 {
top: -180px;
}
.thumb_content { }
I'm sorry if this is not the solution for your problem.

Resources