I am sorry for the very specific question, but I’ve trying to make media queries work, but they won't and don’t even know why.
Basically, when the screen is smaller than 1454px, I want the classes in the media query to apply, that is to say, instead of a box on hover, it’s a simple underlining.
Here is the link to the actual website, if it’s any better.
document.querySelectorAll('a.link-ranking').forEach((aLink, _, arr) => {
aLink.onclick = () => {
arr.forEach(a => a.classList.toggle('link-ranking-active', aLink === a))
}
})
.link-ranking {
box-sizing: border-box;
position: relative;
padding: 8px;
color: #ffffff;
text-decoration: none;
}
.link-ranking::before,
.link-ranking::after {
content: '';
box-sizing: border-box;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform-origin: center;
}
.link-ranking::before {
border-top: 0.15em solid #48ffd5;
border-bottom: 0.15em solid #48ffd5;
border-radius: 0.3em;
transform: scale3d(0, 1, 1);
}
.link-ranking::after {
border-left: 0.15em solid #48ffd5;
border-right: 0.15em solid #48ffd5;
border-radius: 0.3em;
transform: scale3d(1, 0, 1);
}
.link-ranking:hover::before,
.link-ranking:hover::after {
transform: scale3d(1, 1, 1);
transition: transform 700ms;
}
.link-ranking-active {
box-sizing: border-box;
position: relative;
padding: px;
height: 100%;
width: 100%;
border-radius: 0.3em;
border: 0.15em solid #48ffd5;
}
#media screen and (max-width: 1454px) {
.link-ranking {
position: relative;
padding: 0.3em;
color: #ffffff;
text-decoration: none;
padding-bottom: 2px;
transition: all 0.35s linear;
background: linear-gradient(to bottom, #48ffd5 0%, #48ffd5 98%);
background-size: 0px 2px;
background-repeat: no-repeat;
background-position: left 100%;
}
.link-ranking::before,
.link-ranking::after {
content: '';
position: absolute;
bottom: 0;
right: 0;
width: 0;
height: 2px;
background-color: #48ffd5;
transition: width .0.7s cubic-bezier(0.25, 1, 0.5, 1);
}
.link-ranking:hover::before,
.link-ranking:hover::after {
background-size: 100% 2px;
left: 0;
right: auto;
}
.link-ranking-active {
text-decoration: none;
color: #48ffd5;
position: relative;
cursor: pointer;
text-decoration: none;
display: inline;
padding-bottom: 2px;
transition: all 0.35s linear;
background: linear-gradient(to bottom, #48ffd5 0%, #48ffd5 98%);
background-size: 0px 2px;
background-repeat: no-repeat;
background-position: left 100%;
}
}
<div class="ranking" id="ranking">
<ul class="ul-menu">
<li class="li-result"><a class="link-ranking" id="Form">Survey Results</a></li>
<li class="li-result"><a class="link-ranking" id="Comparison">Table of Comparison</a></li>
</ul>
</div>
So while i was going through your stylesheet(main.css), i found that your expression inside media query i.e.
max-width: 1454px
is not as same as this
max-width: 1454px
The reason behind this is there are some hidden characters inside the expression that you have used. You can check this text to ascii converter and try converting the above two blockquotes, their text part looks the same but when converted to ascii they are different. The exact reason behind why this is happening would be vague without further details about the environment you used to write this css, but the solution to your issue is to just replace the existing media query with this max-width: 1454px.
Related
How can i make this buttons responsive?
(with the phone) i want see the buttons with a full width, but i can't and i don't know why!
PS: You can change everything you want, but please help me!
PS2: The buttons have an animation, i know how to block this so use only this code.
If you need more information about this, just ask, i will answer you soon i can! Sorry for my bad english and thank you for the help!
.bottoni {
display: block;
z-index: 999;
width: 100px;
height: 100%;
position: absolute;
top: 50%; bottom: 0; right: 0;
transform:translateX(-190%);
margin-top: -200px;
text-align: left;
}
.bottoni > a {
display: inline-block;
padding: 10px 40px;
min-width: 240px;
margin: 20px;
background: rgba(0, 0, 0, 0.9);
border-left: 15px solid #f45341;
border-right: 3px solid #f45341;
text-decoration: none;
color: #fff;
text-transform: uppercase;
font-size: 30px;
background: linear-gradient(to left, #f45341 50%, rgba(96, 96, 96, 0.4) 50%);
background-position: 0% 0%;
background-size: 200%;
transition: background 150ms ease-in-out, color 150ms ease-in-out;
transition: .3s;
font-family: pricedown;
border-radius: 5px;
text-align: left;
}
.bottoni > a:hover {
color: #fff;
background-position: -100% 0%;
cursor: pointer;
border-left: 15px solid #f45341;
}
.bottoni2 {
display: block;
z-index: 999;
width: 100px;
height: 100%;
margin: 0;
position: absolute;
top: 50%; bottom: 0; left: 0;
transform:translateX(-100%);
margin-top: -200px;
text-align: right;
}
.bottoni2 > a {
display: inline-block;
padding: 10px 40px;
min-width: 240px;
margin: 20px;
background: rgba(0, 0, 0, 0.9);
border-right: 15px solid #f45341;
border-left: 3px solid #f45341;
text-decoration: none;
color: #fff;
text-transform: uppercase;
font-size: 30px;
background: linear-gradient(to right, rgba(96, 96, 96, 0.4) 50%, #f45341 50%);
background-position: 0% 0%;
background-size: 200%;
transition: background 150ms ease-in-out, color 150ms ease-in-out;
transition: .3s;
font-family: pricedown;
border-radius: 5px;
text-align: right;
}
.bottoni2 > a:hover {
color: #fff;
background-position: -100% 0%;
cursor: pointer;
border-right: 15px solid #f45341;
}
#media only screen and (max-width: 768px) {
.bottoni{
width: 100%;
position: relative;
display: inline-block;
transform:translate(0%,0%);
top: 0; bottom: 0; right: 0; left: 0;
}
}
<div class="bottoni">
<a target="blank_" id="store" href="http://store.sparocraft.eu">Store</a>
<a target="blank_" id="votaci" href="http://vota.sparocraft.eu">Votaci</a>
</div>
<div class="bottoni2">
<a target="blank_" id="ts" class="offline" href="ts3server://ts.sparocraft.eu">TeamSpeak</a>
<a target="blank_" id="bans" class="offline" onclick="offline();">Bans</a>
</div>
There are a couple things going on:
First, I changed your CSS to have mobile/small screens first. This way you can have all your styles for the buttons and then just change the positioning for larger screens. Second, you can easily combine styles for your buttons so you don't have a bunch of repeating styles.
Hopefully this is what you're looking for:
* {
box-sizing: border-box;
}
.bottoni,
.bottoni2 {
position: relative;
}
.bottoni > a,
.bottoni2 > a {
display: block;
width: 100%;
padding: 10px 40px;
margin: 20px 0;
background: rgba(0, 0, 0, 0.9);
border-left: 15px solid #f45341;
border-right: 3px solid #f45341;
text-decoration: none;
color: #fff;
text-transform: uppercase;
font-size: 30px;
background: linear-gradient(to left, #f45341 50%, rgba(96, 96, 96, 0.4) 50%);
background-position: 0% 0%;
background-size: 200%;
transition: background .3s ease-in-out, color .3s ease-in-out;
font-family: pricedown;
border-radius: 5px;
text-align: left;
}
.bottoni > a:hover,
.bottoni2 > a:hover {
color: #fff;
background-position: -100% 0%;
cursor: pointer;
}
#media screen and (min-width: 768px) {
.bottoni,
.bottoni2 {
position: absolute;
width: 300px;
top: 50%;
right: 0;
transform: translatey(-100%);
}
.bottoni > a,
.bottoni2 > a {
position: relative;
width: 300px;
}
.bottoni2 {
left: 0;
right: auto;
}
.bottoni2 > a {
border-right: 15px solid #f45341;
border-left: 3px solid #f45341;
}
.bottoni2 > a:hover {
border-right: 15px solid #f45341;
}
}
<div class="bottoni">
<a target="blank_" id="store" href="http://store.sparocraft.eu">Store</a>
<a target="blank_" id="votaci" href="http://vota.sparocraft.eu">Votaci</a>
</div>
<div class="bottoni2">
<a target="blank_" id="ts" class="offline" href="ts3server://ts.sparocraft.eu">TeamSpeak</a>
<a target="blank_" id="bans" class="offline" onclick="offline();">Bans</a>
</div>
Here is the fiddle so you can check it out:
https://jsfiddle.net/sxcg1o7u/1/
I've got an issue with menu styling.
Menu looks like this:
And each element is styled as follows:
.gallery-navi-element {
position: relative;
float: left;
text-align: center;
font-size: 1.7em;
padding: 0px 60px 0px 60px;
margin-top: 10px;
transition: height .8s ease;
}
.gallery-navi-element:hover:after {
content: " ";
position: absolute;
left: 50%;
/* top: 50%; */
transform: translate(-50%,0%);
top: 40px;
width: 0;
height: 0;
border-style: solid;
border-width: 20px 25px 0 25px;
border-color: rgb(74, 125, 51) transparent transparent transparent;
transition: 0.5s all;
}
In this way i can achieve such effect:
Still i'm having serious issues making this triangle stay there after a click. Creating jQuery handlers adding classes seems not to work at all since the new class overwrites navi buttons. Have tried playing with :target but without luck. Any ideas?
EDIT:
Added a fiddle: https://jsfiddle.net/a7zs3z6o/
Add a tabindex to each gallery-navi-element element:
<div class="gallery-navi-element" id="gallery-show-wszystkie" tabindex="1">Wszystkie</div>
That will allow them to be focused when clicked.
You'll then want to remove the default outline that appears on focused elements, which you can do with:
.gallery-navi-element:focus {
outline: none;
}
Updated Fiddle
Instead of changing the navi links' class, just add a new .hover class that has the same styles as :hover. Then you won't have a problem with lots of overwriting styles.
You would probably have less trouble doing this if you simplified the CSS to only include the transitioned styles in the hover state/added-class state.
.gallery-navi-element:after {
content: " ";
position: absolute;
left: 50%;
transform: translate(-50%, 0%);
top: 30px;
width: 0;
height: 0;
border-style: solid;
/* border-width: 0px 25px 0 25px; */
border-width: 10px 25px 0 25px;
border-color: rgb(74, 125, 51) transparent transparent transparent;
transition: 0.5s all;
}
.gallery-navi-element:hover:after,
.gallery-navi-element.hover:after {
top: 40px;
border-top-width: 20px;
}
Note that the only reason for the border-top-width transition is so that your triangle doesn't cover up the bottom of the Y in the first couple links.
Example:
var navLinks = document.getElementsByClassName('gallery-navi-element');
for(var i=0,l=navLinks.length;i<l;i++) {
navLinks[i].addEventListener('click', function(){
for(var i=0,l=navLinks.length;i<l;i++) {
navLinks[i].classList.remove('hover');
}
this.classList.add('hover');
}, false);
}
.gallery-navi {
border-radius: 28px;
width: 950px;
height: 55px;
background-color: rgb(74, 125, 51);
margin: 0px auto 20px auto;
}
.gallery-navi-wrapper {
margin: 0 auto;
width: 870px;
}
.gallery-navi-separator {
width: 2px;
background-color: rgba(255, 255, 255, 0.2);
height: 36px;
float: left;
margin-top: 10px;
}
.gallery-navi-element {
position: relative;
float: left;
text-align: center;
font-size: 1.7em;
padding: 0px 60px 0px 60px;
margin-top: 10px;
transition: height .8s ease;
}
.gallery-navi-element:after {
content: " ";
position: absolute;
left: 50%;
transform: translate(-50%, 0%);
top: 30px;
width: 0;
height: 0;
border-style: solid;
/* border-width: 0px 25px 0 25px; */
border-width: 10px 25px 0 25px;
border-color: rgb(74, 125, 51) transparent transparent transparent;
transition: 0.5s all;
}
.gallery-navi-element:hover:after,
.gallery-navi-element.hover:after {
top: 40px;
border-top-width: 20px;
}
<div class="gallery-navi">
<div class="gallery-navi-wrapper">
<div class="gallery-navi-element" id="gallery-show-wszystkie">Wszystkie</div>
<div class="gallery-navi-separator"></div>
<div class="gallery-navi-element" id="gallery-show-produkty">Produkty</div>
<div class="gallery-navi-separator"></div>
<div class="gallery-navi-element" id="gallery-show-tartak">Tartak</div>
<div class="gallery-navi-separator"></div>
<div class="gallery-navi-element" id="gallery-show-sklad">Skład</div>
</div>
</div>
I am trying to build a progress bar as seen often within checkouts.
The problem is, that the borders between the arrows are transparent and the whole thing should be responsive.
I got it this far:
http://codepen.io/MrBambule/pen/rVBeoz
But I can't figure out how to get the items of the bar to span the whole width of the parent container (red border in the pen) and stay responsive.
I think I could figure it out with JS but I'd rather have a CSS solution.
Help would be much appreciated.
HTML
<ul class="progress-nav">
<li class="active">
<span>1. FOO</span>
</li>
<li>
<span>2. BAR</span>
</li>
<li>
<span>3. BAZ</span>
</li>
</ul>
CSS
$bar-color: rgba(255, 255, 255, 0.2);
$bar-active-color: rgba(255, 255, 255, 0.6);
$arrow-size: 22px;
body {
background: linear-gradient(left, #803689, #5eb6e4);
}
.progress-nav {
position: relative;
font-size: 0;
margin: 100px auto;
width: 80%;
max-width: 900px;
// dummy border to display the width problem
border: 1px solid red;
li {
position: relative;
color: #fff;
font-size: 12px;
display: inline-block;
width: 20%;
margin-right: 48px;
list-style: none;
background: $bar-color;
padding: $arrow-size 0;
transition: background .5s, color .5s;
span {
position: absolute;
width: 100%;
top: 50%;
left: 50%;
transform: translateX(-33px) translateY(-35%);
}
&:before,
&:after {
content: '';
position: absolute;
display: block;
top: 0;
transition: all .5s;
}
&:before {
border: $arrow-size solid $bar-color;
border-left-color: transparent;
left: -$arrow-size*2;
}
&:after {
border: $arrow-size solid transparent;
border-left-color: $bar-color;
right: -$arrow-size*2;
}
&:first-child:before {
border: none;
width: $arrow-size*2;
height: $arrow-size*2;
background: $bar-color;
border-radius: 4px 0 0 4px;
}
&:last-child:after {
border: none;
right: -$arrow-size;
width: $arrow-size;
height: $arrow-size*2;
background: $bar-color;
border-radius: 0 4px 4px 0;
}
&.active,
&:hover {
background: $bar-active-color;
color: #000;
&:before {
border-color: $bar-active-color;
border-left-color: transparent;
}
&:after {
border-left-color: $bar-active-color;
}
&:first-child:before,
&:last-child:after {
background: $bar-active-color;
}
}
}
}
you could use something like:
.wrap {
width: 100%;
height: 30px;
z-index:-2;white-space: nowrap;
overflow:hidden;
}
.wrap div:first-child{margin-left:-2%;}
.progress {
margin:0;
margin-left:0.5%;
height: 30px;
width: 25%;
position: relative;
display: inline-block;
text-align: center;
line-height: 30px;
transition: all 0.8s;
}
.progress:before,
.progress:after {
content: "";
position: absolute;
transition: all 0.8s;
z-index:-1;
}
.progress:before {
height: 50%;
width: 100%;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.2);
-webkit-transform: skew(45deg);
-moz-transform: skew(45deg);
transform: skew(45deg);
}
.progress:after {
height: 50%;
width: 100%;
top: 50%;
left: 0;
background: rgba(0, 0, 0, 0.2);
-webkit-transform: skew(-45deg);
-moz-transform: skew(-45deg);
transform: skew(-45deg);
}
.progress:hover:before,
.progress:hover:after {
background: tomato;
}
<div class="wrap">
<div class="progress">
simple
</div>
<div class="progress">
as
</div>
<div class="progress">
complex
</div>
<div class="progress">
Web Development
</div>
</div>
which is responsive to the width of the screen.
It makes use of the transform:skew property for the middle bars, and a small border hack for the two far elements. This results in the output shown below:
Result
NOTE
If you are creating these dynamically (and want them all along the same line), then you will need to alter the width stated in the first css rule (currently set to 23%).
http://jsfiddle.net/93bphr4f/
html:
<button type="button" onClick="location.href='#'" class="buttonpink2">Claim 10 Free Student Accounts for Your School</button>
css:
/* PINK BUTTON 2 */
.buttonpink2 {
font-weight: bold;
font-size: 30px;
color: white;
cursor: pointer;
cursor: hand;
border-radius: 5px !important;
box-shadow: 4px 4px 4px #b5bcc2;
border: 0;
background-repeat: no-repeat;
background: #e57780;
height: 75px;
width: 100%;
position: relative;
}
.buttonpink2:after {
border-radius: 5px !important;
content: "Claim 10 Free Student Accounts for Your School";
display: block;
height: 100%;
width: 100%;
opacity: 0;
background: #c24e57;
-moz-transition: all 1s;
-webkit-transition: all 1s;
transition: all 1s;
top: 0;
left: 0;
position: absolute;
}
.buttonpink2:hover:after {
opacity: 1;
}
.buttonpink2 p {
color: #fff;
z-index: 1;
position: relative;
}
look at it,
I dont know why when I hover mouse on button, text move to top..
I want to text be still on center of button.
What i doing wrong?
Anyone can help?
Don't know why you complicated it too much but you simple use line-height equal of element height:
/* PINK BUTTON 2 */
.buttonpink2 {
font-weight: bold;
font-size: 30px;
color: white;
cursor: pointer;
cursor: hand;
border-radius: 5px !important;
box-shadow: 4px 4px 4px #b5bcc2;
border: 0;
background-repeat: no-repeat;
background: #e57780;
height: 75px;
width: 100%;
position: relative;
}
.buttonpink2:after {
border-radius: 5px !important;
content: "Claim 10 Free Student Accounts for Your School";
display: block;
height: 100%;
width: 100%;
opacity: 0;
background: #c24e57;
-moz-transition: all 1s;
-webkit-transition: all 1s;
transition: all 1s;
top: 0;
left: 0;
position: absolute;
line-height: 75px;/*add line height equal of element height*/
}
.buttonpink2:hover:after {
opacity: 1;
}
.buttonpink2 p {
color: #fff;
z-index: 1;
position: relative;
}
<button type="button" onClick="location.href='./freeaccess'" class="buttonpink2">Claim 10 Free Student Accounts for Your School</button>
You shouldn't use the :after tag at all in this situation.
// All the positioning made the button go crazy.
You should do it this way:
Use .buttonClass { } to set the basic button styling, and use .buttonClass:hover { } to only change the background of the button. You don't have to duplicate every item in the :hover part.
/* PINK BUTTON 2 */
.buttonpink2 {
font-weight: bold;
font-size: 30px;
color: white;
cursor: pointer;
border-radius: 5px;
box-shadow: 4px 4px 4px #b5bcc2;
border: 0;
height: 75px;
width: 100%;
background: #e57780;
-moz-transition: all 1s;
-webkit-transition: all 1s;
transition: all 1s;
}
.buttonpink2:hover {
background: #c24e57;
}
.buttonpink2 p {
color: #fff;
z-index: 1;
}
Strange way to do, why are you using pseudo-elements just in order to change background-color ?
.buttonpink2:after {
height: 75px;
line-height:75px;
...
}
will solve your problem, but I suggest you to remove the .buttonpink2:after element and just change the background-color of the button
If you would rather using padding instead of line-height, you can do this:
.buttonpink2:after {
height: 50%;
padding: 20px 0;
}
You can add some letter-spacing on :after to solve it, I just added 0.3px, you can try other values to make it better.
/* PINK BUTTON 2 */
.buttonpink2 {
font-weight: bold;
font-size: 30px;
color: white;
cursor: pointer;
cursor: hand;
border-radius: 5px !important;
box-shadow: 4px 4px 4px #b5bcc2;
border: 0;
background-repeat: no-repeat;
background: #e57780;
height: 75px;
width: 100%;
position: relative;
}
.buttonpink2:after {
border-radius: 5px !important;
content: "Claim 10 Free Student Accounts for Your School";
display: block;
height: 100%;
width: 100%;
opacity: 0;
background: #c24e57;
-moz-transition: all 1s;
-webkit-transition: all 1s;
transition: all 1s;
top: 0;
left: 0;
position: absolute;
letter-spacing: 0.3px
}
.buttonpink2:hover:after {
opacity: 1;
}
.buttonpink2 p {
color: #fff;
z-index: 1;
position: relative;
}
<button type="button" onClick="location.href='#'" class="buttonpink2">Claim 10 Free Student Accounts for Your School</button>
I'm not new to CSS but for some reason I've not played with animations or transitions up to this point. I want to learn how to apply any form of transition to a tooltip that I've made, but every time I read code and then try I seem to fail. I have a quick example of code I put together and maybe someone can quickly show me what I'm doing wrong.
Note: This is only an example, I don't plan to use a 2 second transition, makes it clear that it's working.
Following is the key code, please see the jsfiddle here.
label[data-tooltip] {
border-bottom: 1px dotted rgba(0, 0, 0, 0.3);
padding-bottom: 2px;
position: relative;
cursor: pointer;
&:hover:after {
transition: all 2s ease-in-out;
.borderRadius(3px);
content: attr(data-tooltip);
background: rgba(83, 83, 83, 0.95);
text-transform: none;
position: absolute;
line-height: 18px;
padding: 5px 10px;
font-size: 13px;
width: 100px;
z-index: 99;
color: #fff;
bottom: 120%;
left: -5px;
}
&:after {
display: none;
}
&:hover:after {
display: block;
}
}
Try this solution
you should assign all the styles to the after
and to the hover status just the attribute you want to animate
label[data-tooltip] {
border-bottom: 1px dotted rgba(0, 0, 0, 0.3);
padding-bottom: 2px;
position: relative;
cursor: pointer;
&:after {
transition: all ease 5s;
content: attr(data-tooltip);
background: rgba(83, 83, 83, 0.95);
text-transform: none;
position: absolute;
line-height: 18px;
padding: 5px 10px;
font-size: 13px;
width: 100px;
z-index: 99;
color: #fff;
bottom: 120%;
left: -5px;
opacity: 0;
}
&:hover:after {
opacity: 1;
}
}
.formRow {
background: #EFEFEF;
margin: 50px auto;
padding: 10px;
width: 50%;
}
.formRow-label {
display: inline-block;
margin-right: 20px;
}
.formRow-input {
display: inline-block;
}