Here's my CSS menu I've created.
When I see this in my mobile (iPhone 6), the last menu (Menu4) does not show At All. The first 3 menus stretch from left to the right of the phone screen. I can't figure out why.
Could someone help out please?
Here's the HTML part
<hr class="navHr">
<nav id="m">
Menu1
Menu2
Menu3
Menu4
</nav>
<hr class="navHr">
And the CSS part
.navHr {
border: 0;
height: 0.1em;
margin: 0;
background-image: -webkit-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -moz-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -ms-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
background-image: -o-linear-gradient(left, rgba(0,0,0,0), rgba(0,0,0,0.75), rgba(0,0,0,0));
}
nav {
height: 2em;
background: #000;
background: linear-gradient(to bottom, rgba(76, 76, 76, 1) 0%, rgba(44, 44, 44, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(19, 19, 19, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313',GradientType=0 );
line-height: 2em;
text-transform: uppercase;
text-align: center;
min-width: 2em;
position: relative;
}
nav::before {
background: linear-gradient(to top, rgba(76, 76, 76, 0) 0%, rgba(44, 44, 44, 1) 50%, rgba(0, 0, 0, 1) 51%, rgba(19, 19, 19, 1) 100%);
content: '';
display: block;
position: absolute;
top: 100%;
left: 0;
width: 100%;
height: 100%;
opacity: 0.09;
}
nav a {
color: #FFF;
text-decoration: none;
font-weight: bold;
font-size: 1.2em;
border-right: solid 0.1em #FFF;
height: 100%;
padding: 0.25em 3em;
position: relative;
}
nav a:first-child {
border-left: solid 0.1em #FFF;
}
nav a::before {
content: attr(data-mirror);
position: absolute;
top: 100%;
left: 3em;
color: #000;
transform: scaleY(-1);
color: #FFF;
opacity: 0.5;
}
#m {
background-color: #000000;
}
I've checked on your code, try adding "display:inline-block" on your anchor tag, and you will see your column 4 appearing, the fourth one goes beneath the second one in small screens, since the position is relative, try it here :
Columns
Basically, what you are looking for, is displaying an element as an inline-level block container to avoid dislocation. The inside of this block is formatted as block-level box, and the element itself is formatted as an inline-level box, which shapes the navigation of these 4 columns sitting next to each other.
Why do we use inline-block ?
Inline-block makes the element generate a block box that’s laid out as if it were an inline box.
An inline block is placed inline (ie. on the same line as adjacent content), but it behaves as a block.
Basically, it’s a way to make elements inline, but preserving their block capabilities such as setting width and height, top and bottom margins and paddings etc.
Related
I built a basic web and I'm trying to make it responsive, but I'm having some issues with the slider itself; some elements don't center when I resize the screen; I thought it was because of Firefox, but I tried on chrome and the result is the same.
The slider is:
<div id="slider" class="slider-big">
<div class="vertical-relative-centered">
<h1>Welcome everyone!!!</h1>
Ir al Blog
</div>
</div>
And the css:
#slider {
width: 100%;
height: 350px;
/* line-height: 320px; */
color: #fff;
text-shadow: 0 0 5px #444;
overflow: hidden;
background: rgba(73,155,234,1);
background: -moz-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, rgba(73,155,234,1)), color-stop(100%, rgba(32,124,229,1)));
background: -webkit-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: -o-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: -ms-radial-gradient(center, ellipse cover, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
background: radial-gradient(ellipse at center, rgba(73,155,234,1) 0%, rgba(32,124,229,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#499bea', endColorstr='#207ce5', GradientType=1 );
}
#slider h1 {
margin: 0;
padding: 0;
text-align: center;
}
.btn-white {
display: inline-block;
color: rgb(88, 88, 88);
background-color: white;
padding: 10px;
margin: auto;
margin-top: 40px;
font-size: 18px;
text-transform: uppercase;
text-shadow: none;
box-shadow: 0 0 5px rgb(88, 88, 88);
border-radius: 4px;
transition: 300ms all;
}
.btn-white:hover {
background-color: #444;
color: white;
}
The thing is that the h1 moves left when I resized the screen, so my solution was to add an overflow: hidden to #slider, and it works quite well, but I got another issue which is because of the overflow, the slider doesn't stick to the header when I resize; then, I removed the overflow and I tried to center it horizontally with a translateX(), but the h1 ignored it.
So, at the end, I don't know how to center the element in a right way and, at the same time, get the slider sticks to the header.
This is the full code in case you need it: https://jsfiddle.net/ilos28/t9ouea7v/
Thanks in advance.
-------------- Added ---------------
This is the difference, when I change the wide of the screen:
Before:
After:
In the end I just had to set a height 100% in the #menu and the space disappeared.
I have a menu where I want to have an active state and a hover state of the menu items. My problem is illustrated best in the two images. The green background color should only cover the dark orange area (Which is an image).
This is my menu now:
And this is how I want it to be:
Which way is best to cut the bottom of the green element to get this effect?
My code so far in JSFIDDLE:
http://jsfiddle.net/HC5qC/
CSS:
nav ul {
padding: 0;
list-style-type: none;
position: absolute;
right: 96px;
top: 37px;
}
nav li {
float: left;
}
nav a {
text-decoration: none;
font-weight: 400;
font-size: .9375em;
text-transform: uppercase;
letter-spacing: 0.05em;
color: #fff;
padding: 54px 15px 65px 15px;
overflow: hidden;
}
.current-menu-item a,
.current-menu-item a:hover {
background: #79bd8f; /* Old browsers */
background: -moz-linear-gradient(top, #79bd8f 30%, #00a388 99%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(30%,#79bd8f), color-stop(99%,#00a388)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #79bd8f 30%,#00a388 99%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #79bd8f 30%,#00a388 99%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #79bd8f 30%,#00a388 99%); /* IE10+ */
background: linear-gradient(to bottom, #79bd8f 30%,#00a388 99%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#79bd8f', endColorstr='#00a388',GradientType=0 ); /* IE6-9 */
}
nav a:hover {
background: #6b1600;
background: rgba(107, 22, 0, 0.2);
}
I wonder if something like this FIDDLE might get you started.
I'll play around with it a bit more, to see how close we might get to what you want.
But the concept is to put an :after or :before, or an absolutely positioned "overlay" and be able to click to boxes behind.
CSS
.selector {
width: 295px;
height: 100px;
overflow: hidden;
background-color: transparent;
position: relative;
}
.button1 {
float: left;
width: 32%;
height: 100%;
border: 1px solid white;
background-color: blue;
}
.selector:after {
content: '';
width: 300px;
height: 30px;
position: absolute;
top: 85px;
left: 0px;
transform: rotate(-3deg);
background-color: red;
}
So, I am trying to use pure CSS to have a slight dropshadow that lays over a tab. I want it to fade out on the ends at 20% and 80%. I've been trying to acheive this for some time now, but finding myself not happy with the results so far.
Here's an image of what I want to have:
HTML:
<button type="button" class="btn">
<span>Button Text</span>
<span class="buttonshadow"></span>
</button>
CSS:
.btn {
-webkit-border-radius: 0px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius: 0px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-radius: 0px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
font-size: 24px;
padding: 6px 16px 7px;
line-height: 1;
position: relative;
color: #ffffff;
background-color: #5CBCEC;
border-color: #5CBCEC;
display: inline-block;
margin-bottom: 0;
background-image: none;
border: 1px solid transparent;
white-space: nowrap;
overflow: visible;
}
.buttonshadow {
width: 120%;
height: 100%;
position: absolute;
top: 0;
left: -10%;
}
.buttonshadow:before {
content: "";
position: absolute;
z-index: 1;
top: -1px;
left: 0;
width: 100%;
height: 5px;
background: -webkit-radial-gradient(50% -3%, ellipse cover, rgba(00, 00, 00, 0.2), rgba(97, 97, 97, 0.0) 40%);
background: radial-gradient(ellipse at 50% 0%, rgba(0, 0, 0, 0.4), rgba(97, 97, 97, 0) 70%);
}
Here's my current fiddle so far: JSFiddle
Clearly this does not look the same. Any help is much appreciated!!!
If i understand the problem correctly you want the gradient outside the button on the edges.
problem lies in the .buttonshadow and .buttonshadow:before
I changed it to this
.buttonshadow {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: -25px;
}
.buttonshadow:before {
content: "";
position: absolute;
z-index: 1;
top: -1px;
left: 0;
width: 130%;
height: 5px;
background: -webkit-radial-gradient(50% -3%, ellipse cover, rgba(00, 00, 00, 0.2), rgba(97, 97, 97, 0.0) 40%);
background: radial-gradient(ellipse at 50% 0%, rgba(55, 55, 55, 1), rgba(97, 97, 97, 0) 80%);
}
Check fiddle
http://jsfiddle.net/rLsbC/1/
you can then fiddle around with the gradient to get more what you want.
Hope this helps!
Note: If you want to change the width of the gradient change the width in .buttonshadow:before and the left attribute in .buttonshadow
This is one solution that may work for you.
Demo Fiddle
In order to get the fading at the ends I had to squish the radial gradient down a bit, and then position it to look right. I added it to the .btn class instead of a separate element.
CSS:
.btn:after {
content: '';
display: block;
position: absolute;
width: 120%;
height: 5px;
top: -2px;
left: -10%;
background: -webkit-radial-gradient(center, ellipse cover, rgba(0,0,0,0.45) 0%,rgba(0,0,0,0) 85%);
}
[me, earlier via comments] I’d try with just a linear gradient for the span over the whole width of the button, and then add a faded shadow via an elliptical gradient on both sides using :before/ :after elements on the span …
OK, I gave it a go now – http://jsfiddle.net/rLsbC/3/
Sorry, it’s Firefox only for now as I didn’t bother with vendor prefixes for other browsers – but to add those should be not a big deal. (For those that actually support radial gradients anyway.)
I replaced the shadow in the span element itself with a linear gradient,
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.4) 0%,
rgba(97, 97, 97, 0) 100%);
and then added positioned :before/:after with an elliptical radial gradient positioned at the top right resp. top left corner of those generated elements, like this
background: -moz-radial-gradient(top right, ellipse cover, rgba(0, 0, 0, 0.4),
rgba(97, 97, 97, 0) 50%);
Had to make the span element itself a little higher to get the linear gradient and the elliptical ones stuck to the sides of it to match up.
If you take that as a basis and play around with the specific values of the gradients (and maybe the width/position of the generated elements), you should be able to get very close to what you want.
I am trying to make buttons using CSS, instead of using image sprites.
These are going to be across the site with different text, so making a large image sprite does not make sense, especially since the size of the buttons vary according to the text.
This is what I've been able to achieve : (very different from the original one)
Fiddle Link
a {
display: inline-block;
line-height: 20px;
text-decoration: none;
font-family: 'Arial';
font-size: 19px;
font-weight: 700;
color: #ddd;
padding: 10px 20px;
border-radius: 5px;
border: 1px solid #001151;
text-shadow: 2px 2px 4px rgba(32,70,97,.55);
background: #002483;
background: linear-gradient(
to bottom,
rgba(0,36,131,1) 0%,
rgba(0,44,151,1) 27%,
rgba(0,61,166,1) 55%,
rgba(15,77,180,1) 82%,
rgba(23,83,185,1) 100%);
}
P.S. : (Browser Support >= IE9)
Is creating buttons like these possible using only HTML + CSS?
Don't get me wrong, but this button is ugly :). The standard nowdays is to make buttons as simple as possible with very subtle gradients.
Here is my try though, CSS only: http://jsfiddle.net/9CPBY/1/
I have used before to add the reflexion and after to add the spotlight glare.
a:after{
content:".";
position:absolute;
color:transparent;
width:1px;
height:1px;
background:white;
top:5px;
left:70%;
border-radius:10px;
box-shadow:0px 0px 20px 10px white;
}
Gradient generated using ColorZilla's generator.
Only tested in Chrome, should work fine in other browsers too.
Here is an example that has glare. You need to do it with 2 divs
DEMO http://jsfiddle.net/kevinPHPkevin/hZgxV/
HTML
<div id="blue_button" >
<div class="blue_glare"></div>
</div>
CSS
#blue_button {
margin-top:20px;
height: 30px; width: 150px;
border-radius: 16px;
border: 2px solid #ccc;
text-align: center;
background-color: rgba(60, 132, 198, 0.8);
background-image: -webkit-gradient(linear, 0% 0%, 0% 90%, from(rgba(28, 91, 155, 0.8)), to(rgba(108, 191, 255, .9)));
background-image: -moz-linear-gradient(top, #1c5b9b, #6cbfff);
border-top-color: #8ba2c1;
border-right-color: #5890bf;
border-bottom-color: #4f93ca;
border-left-color: #768fa5;
box-shadow: rgba(66, 140, 240, 0.5) 0px 10px 16px;
float: left;
margin-right: 30px;
}
.blue_glare {
top: 0;
left: 5px;
border-radius: 8px;
height: 1px;
width: 142px;
padding: 8px 0;
background-color: rgba(255, 255, 255, 0.25);
background-image: -webkit-gradient(linear, 0% 0%, 0% 95%, from(rgba(255, 255, 255, 0.7)), to(rgba(255, 255, 255, 0)));
margin: 0 auto;255
z-index: 10;
}
CSS is fairly limited in this regard, unfortunately. However, you could always embed an image into the CSS using Base64 format.
Trying to simulate this progress bar using css. It has two backgrounds and one of the backgrounds should only cover a part of the bar, behind the text. The width of it should be easy to manipulate to change the %.
I started with the a full bar, but really not sure how add the percentage part to it. Is it possible to do without absolute positioning?
<div class="bar">
Progress: 60%
</div>
.bar {
border: 1px solid black;
color: white;
display: table-cell;
width: 250px;
height: 50px;
text-align: center;
vertical-align: middle;
background: #003458;
background: -moz-linear-gradient(top, #003458 0%, #001727 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#003458), color-stop(100%,#001727));
background: -webkit-linear-gradient(top, #003458 0%,#001727 100%);
background: -o-linear-gradient(top, #003458 0%,#001727 100%);
background: -ms-linear-gradient(top, #003458 0%,#001727 100%);
background: linear-gradient(to bottom, #003458 0%,#001727 100%);
}
Fiddle
If you just want to lighten up like your example demonstrates, overlay 2 gradients:
.bar {
background: linear-gradient(to right, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.1) 60%, transparent 60%),
linear-gradient(to bottom, #003458 0%,#001727 100%);
}
Here is a demo. (Removed the vendor prefixes, you should add them again in the final code)
But the problem is, how would you know how large the bar should be? You could create several classes for each value or use JavaScript for this, but of course both solutions are not good. So like others said: Use an inner element:
<div class="bar">
<p>Progress: 60%</p>
<span style="width: 60%"></span>
</div>
CSS:
.bar {
position: relative;
border: 1px solid black;
color: white;
display: block;
width: 250px;
text-align: center;
vertical-align: middle;
height: 50px;
line-height: 50px;
background: linear-gradient(to bottom, #003458 0%,#001727 100%);
}
.bar > span {
position: absolute;
display: block;
top: 0;
left: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.1);
}
.bar > p {
display: inline;
position: relative;
z-index: 1;
}
With that you can style the value by setting the width within the <span/>'s style attribute. Btw.: I changed the display: table-cell to block and added line-height to vertically center the text. This should work in this case because there is no line break. Besides that, position: relative does nothing on table cells.
Here is a demo.