I don't understand why my menu is not centering. I tried everything from inline elements to margin: 0 auto; to align="center" and I can not get the menu to center. You can see it here http://jeremyspence.net78.net you have to scroll down all the way to see it, t only appears when it goes past the main menu. Here is some css
.scrollmenu {
display:none;
position: fixed;
top: 0;
text-align:center;
margin: 0px auto;
width: 1020px;
z-index: 10000;
padding:0;
}
.scrollmenu li{
width: 200px;
height: 75px;
overflow: hidden;
position: relative;
float:left;
background: #fff;
-webkit-box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
-moz-box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
box-shadow: 1px 1px 2px rgba(0,0,0,0.2);
margin-right: 4px;
-webkit-transition: all 300ms linear;
-moz-transition: all 300ms linear;
-o-transition: all 300ms linear;
-ms-transition: all 300ms linear;
transition: all 300ms linear;
}
.scrollmenu li:last-child{
margin-right: 0px;
}
.scrollmenu li a{
text-align: left;
width: 100%;
height: 100%;
display: block;
color: #000;
position: relative;
}
.scroll-icon{
font-family: 'Symbols';
font-size: 60px;
color: #333;
text-shadow: 0px 0px 1px #333;
line-height: 80px;
position: absolute;
width: 100%;
height: 50%;
left: 0px;
top: 0px;
text-align: center;
}
.scroll-home{
font-size: 30px;
opacity: 0.8;
text-align: center;
position: absolute;
left: 0px;
width: 100%;
height: 50%;
top: 30%;
}
.scrollmenu li:nth-child(2):hover{
background-color: #CEFECE;
}
.scrollmenu li:nth-child(3):hover{
background-color: #CEFEFE;
}
.scrollmenu li:nth-child(4):hover{
background-color: #CECEFE;
}
.scrollmenu li:last-child:hover{
background-color: #FECEFE;
}
Just add this on your <ul class="scrollmenu"></ul> :
left: 50%;
margin-left: -510px;
or :
left: 0;
right: 0;
Looks like you're centering a div? <div> is a block element, by default. They're centered by using margins. You were close -- you need to make both the left AND right margin auto. margin-left:auto;margin-right:auto;. That will center it inside its parent element, which needs to be 100% width (block elements will expand to maximum width of parent by default). If it's an inline element, you can use text-align:center; on its parent (parent still needs to be 100% width), and that will do the trick.
In the HTML for your link, it looks like you need to set the position:fixed in the div above the ul menu. It looks like you're setting both position:fixed and trying to center at the same time. Get the parent div positioned in the fixed location, and then its child ul should be able to be centered via margin-left: auto; margin-right: auto;.
Have you tried giving a width to the content div?
.content {
position: relative;
width: 1024px;
margin: 0 auto;
}
That seems to solve the issue in Chrome.
By setting position: fixed; without a size for the enclosing container, the menu uses the window border for the container, then with all the items floating left... well they all are on the left.
Related
The nav buttons sit on top of the image title div. Both drop down on hover. When going to the next image, the nav buttons are at the correct location, but when you click on the previous, the whole nav screen shifts to the bottom right!
nav {
position: absolute;
width: 100%
height: 20px;
padding-bottom: 2px;
z-index: 1;
float: right;
margin-top: -20px;
transition: margin-top 200ms ease-in;
background: black;
opacity: 0.4;
right: 1px;
}
.title {
position: absolute;
width: 85%;
height: 20px;
padding-bottom: 2px;
margin-top: -25px;
transition: margin-top 200ms ease-in;
background: black;
color: white;
opacity: 0.6;
}
.title-text {
float: left;
padding-left: 5px;
}
.slides:hover .title {
margin-top: 0px;
}
Here is link to a fiddle.
I fixed this part but code itself is clumsy
anyway still here is example : jsfiddle
first of all you forgot ";" in .nav { between height and width
secondly dont use position: absolute and float it exclude each other
try to connect similiar classes like your buttons
.btn-prev,
.btn-next{
color: black;
background:white;
border: 2px solid white;
margin: 0px 5px 0px 0px;
cursor: pointer;
padding: 0px 5px 0px 5px;
display: inline-block;
}
Quick explain, I set text-align on .nav element so buttons would be set on right side inside .nav and .btn-* for display: inline-block; (default
display: block; so it would behave similiar like text.
So I have an "in-development" website and I'm seeing a weird issue in Google Chrome (Edge/Internet Explorer is not showing this bug, but works as intended, which is a first!)
The two "Next" and "Previous" controls for cycling through the header images have a z-index of 666 and are floated left and right, but it seems that Google Chrome is not detecting a) the hover event, b) the click (as far as I can tell). I don't know if this is related to the menu at the bottom of the header...
Any help would be much appreciated!
CSS Code below:
#header #coverControls-prev,
#header #coverControls-next {
position: relative;
height: 100%;
width: 100px;
background-color: rgba(0,0,0,0.0);
opacity: 0.25;
text-align: center;
transition: opacity 0.5s ease-in-out, background-color 0.5s ease-in-out;
z-index: 666;
}
#header #coverControls-prev:hover,
#header #coverControls-next:hover {
background-color: rgba(0,0,0,0.25);
opacity: 1;
}
#header #coverControls-prev {
float: left;
clear: none;
}
#header #coverControls-next {
float: right;
clear: none;
}
#header #coverControls-prev p,
#header #coverControls-next p {
display: block;
position: absolute;
top: 50%;
margin-top: -50%;
width: 100%;
font-size: 10vmin;
text-align: center;
z-index: 667;
}
#menu {
position: absolute;
bottom: 0;
left: 0;
display: block;
padding: 5px 2vw;
height: 3em;
width: 100vw;
background-color: rgba(255,255,255,0.5);
text-align: left;
white-space: nowrap;
overflow: hidden;
color: #000000;
z-index: 777;
}
Website in question: http://dev1.deliriousdreams.co.uk/
add this to your a tags in css. Your anchor tag needs a width and height. And display:block allows you to add width and height for an anchor tag.
width: 100px;
height: 100px;
display: block;
I have a floating modal shopping cart that sits at the top of my shopping page (metronic theme). The problem I face is that if a user adds too many products, it falls off the bottom of the page.
I thought of two solutions:
Using paging
Using overflow scroll
Overflow scroll seems the most sensible solution although this is the issue:
When I only have 1 product in the cart, I end up with a chunky look due to empty white space below the product, which is not great:
My CSS is as follows:
.cart-content-wrapper{
position: absolute;
right: -2px;
top: 100%;
z-index: 99999;
}
.cart-content {
padding: 8px 0 10px;
background: #fcfafb;
border-top: solid 2px #ea4c1d;
box-shadow: 5px 5px rgba(91, 91, 91, 0.2);
width: 364px;
margin-top: 12px;
color: #717880;
display: none;
position: relative;
overflow: scroll;
overflow-x: hidden;
height: 400px;
transition: opacity .3s ease-in-out;
-moz-transition: opacity .3s ease-in-out;
-webkit-transition: opacity .3s ease-in-out;
}
.cart-content:after {
top: -8px;
width: 0;
height: 0;
right: 8px;
z-index: 2;
content: " ";
display: block;
position: absolute;
border-bottom: 8px solid #e6400c;
border-right: 8px solid transparent;
border-left: 8px solid transparent;
}
So my question is this:
What is the best way to dynamically re-size the modal so that it does not end up with empty space?
This can be achieved by using the properties min-width and/or max-width:
Let's say you want the height to always be at least 100px tall but never more than 200px:
div {
min-height: 100px;
max-height: 200px;
height: auto; /* Not necessary as it is the default value */
}
Now the div will always be 100px tall unless there is more content, which will stretch the div. When 200px is reached and you want a scrollbar, you can add overflow: auto.
I try to have a div that fit it width from image child. It works in google chrome, safari but not in =< IE9 and some other browsers...This div is responsive and the height is in % defined by js.
Here the html code :
<div class="element wide music">
<div class="element-container element-back-bg5">
<div class="audio-player-cover">
<img class="cover" src="http://www.konbini.com/fr/files/2013/04/Random-Access-Memories-Daft-Punk-88883716862.png" alt="" />
</div>
<div class="audio-player-informations">
<div class="element-audio-separator"></div>
<div class="audio-player-songtitle">Get Lucky feat Colin Farrell</div>
</div>
</div>
</div>
And the css :
.element {
position: relative;
overflow: hidden;
cursor: pointer;
float: left;
width: 450px;
height: 180px;
border: none;
}
.element-container {
position: absolute;
overflow: hidden;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: 2px!important;
-webkit-box-shadow: 0px 2px 6px 0px rgba(0,0,0,0.5);
-moz-box-shadow: 0px 2px 6px 0px rgba(0,0,0,0.5);
/*box-shadow: 0px 2px 6px 0px rgba(0,0,0,0.5);*/
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
.audio-player-cover div {
position: relative;
height: 100%;
width: auto;
float: left;
}
.audio-player-informations {
position: relative;
overflow: hidden;
height: 100%;
}
.audio-player-cover img.cover {
position: relative;
height: 100%;
min-height: 100%;
max-height: 100%;
width: auto;
float: left;
}
.audio-player-artiste {
position: relative;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
width: 100%;
height: 30px;
box-sizing: border-box;
opacity: 1;
font-family: 'MavenProLight-300';
font-size: 16px;
line-height: 30px;
text-align: left;
}
/* Title */
.audio-player-songtitle {
position: relative;
overflow: hidden;
text-overflow: ellipsis;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
width: 100%;
height: 30px;
margin-top: 20px;
box-sizing: border-box;
opacity: 1;
font-family: 'MavenProLight-300';
font-size: 20px;
line-height: 30px;
text-align: left;
}
.element-back-bg5 {
background:#ECEDF0;
color: #58585C;
}
.element-audio-separator {
position: absolute;
overflow: hidden;
width: 3px;
height: 100%;
left: 0;
top: 0;
border-left: 1px solid rgba(0,0,0,0.05);
-webkit-box-shadow: inset -1px 0px 2px 0px rgba(0,0,0,0.2);
-moz-box-shadow: inset -1px 0px 2px 0px rgba(0,0,0,0.2);
box-shadow: inset -1px 0px 2px 0px rgba(0,0,0,0.2);
}
.element.wide .audio-player-songtitle, .element.square .audio-player-artiste {
padding-left: 5%;
padding-right: 5%;
}
And the fiddle; http://jsfiddle.net/zKEkG/1/
I'm sorry but your css is very messy. It looks like you're lacking a good understanding of the box model and how positioning works. I recommend you read:
More about box model:
http://learn.shayhowe.com/html-css/box-model
More about how to use positioning properly using css:
http://www.barelyfitz.com/screencast/html-training/css/positioning/
As for a quick fix to your problem, if you set the height of the cover image directly to the height of the container, it should work cross browser.
.audio-player-cover img.cover {
/*Manually set height to match container*/ height: 180px;
min-height: 100%;
max-height: 100%;
width: auto;
float: left;
}
Edited:
Misinterpreted question. Seems like the issue is stricter css selector.
Changed: audio-play-cover to div.audio-player-cover
jsfiddle: jsfiddle.net/zKEkG/8
I am using pure CSS based tooltip, but having display issue. The span box is hiding behind main boday and facebook like box which is in right sidebar. Below is the screenshot of the same.
Here is the tooltip CSS.
a.tooltip
{
position: relative;
display: inline-block;
}
a.tooltip span {
position: absolute;
width: 300px;
padding: 8px;
left: 50%;
font-size: 13px;
line-height: 16px;
margin-left: -160px;
text-align: justify;
visibility: hidden;
bottom: 40px; /** Use 30px for simple fade in effect - Removes slide down effect **/
opacity: 0;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-transition: all 0.2s ease-in-out;
-moz-transition: all 0.2s ease-in-out;
-o-transition: all 0.2s ease-in-out;
-ms-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
/** CSS Down Arrow **/
a.tooltip span:after {
content: '';
position: absolute;
bottom: -14px;
left: 50%;
margin-left: -9px;
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
}
a:hover.tooltip span {
opacity: 1;
visibility: visible;
bottom: 30px;
z-index: 100;
}
a.imgleft {
float: left;
margin: 0 15px 10px 0;
}
a.imgright {
float: right;
margin: 0 0 10px 15px;
}
a.imgleft span, a.imgright span {
bottom: 140px;
}
a:hover.imgleft span, a:hover.imgright span {
bottom: 130px;
}
/** Span Color **/
a.ttblue {
color: #E45742;
}
a.ttblue span {
background: #E45742;
border: 4px solid #E45742;
color: #FFF;
}
a.ttblue span:after {
border-top: 10px solid #E45742;
}
any help will be greatly appreciated! Thanks
I believe we had to see more of your pages html to be able to help you.
However, the only problem I can imagine is .tooltip being in a different stacking context than right sidebar's.
Does any of .tooltip's parents/grandparents have a z-index or an opacity level set on it? It might be an opacity level. If it is, set a positive z-index on it (or if sidebar has a z-index too, a higher one than sidebar's).