Please, advise how to make circle around the bullet using CSS, when the bullet (slide) is active?
Right now my css code is:
.slide-dot {
cursor: pointer;
height: 10px;
width: 10px;
text-decoration: none;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
}
.active {
background-color: #FFE600;
}
Example:
Add padding and transparent border to the dot. Use background-clip: content-box to prevent the background from effect the padding and border area. Change the color of the border to currentColor when active.
Note: I've used currentColor to control the background and border via one property.
.slide-dot {
cursor: pointer;
height: 10px;
width: 10px;
text-decoration: none;
color: #bbb;
background-color: currentColor;
border-radius: 50%;
display: inline-block;
padding: 5px;
background-clip: content-box;
border: 1px solid transparent;
}
.active {
color: #FFE600;
border-color: currentColor;
}
<div class="slide-dot"></div>
<div class="slide-dot active"></div>
<div class="slide-dot"></div>
<div class="slide-dot"></div>
<div class="slide-dot"></div>
div {
margin-top: 50px;
}
.dot {
cursor: pointer;
height: 12px;
width: 12px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active,
.dot:hover {
background-color: black;
border: 1px solid yellow;
border-radius: 50%;
position: relative;
box-shadow: 0 0 0 1px #cfd1d1;
}
<!-- The bullets -->
<div style="text-align:center">
<span class="dots"><span class="dot" onclick="currentSlide(1)"></span></span>
<span class="dots"><span class="dot" onclick="currentSlide(2)"></span></span>
<span class="dots"><span class="dot" onclick="currentSlide(3)"></span></span>
</div>
Hope you can get some idea through this :)
Related
I hava made two buttons by CSS imitating the work from https://codepen.io/xflotus/pen/deXBzR. But they will move together when clicking one of them. I have checked the code carefully, but can not find the clue. The pen of the code is at: https://codepen.io/xflotus/pen/gzWyrg. I think the :active is not the problem:
.button:active {
margin: 2px 0px 20px 10px;
}
But, I have no idea how to find the bug. Thanks!
Changing margins is not the best way to make a movement of a button in active state because the entire container moves down. For the movement of a single button try this code instead and remove the old code with margins:
.button:active{transform:translateY(10px)}
Now only one button will move instead of both. You can also aply -webkit-transform property if you need support in older browsers, but it's not required for new ones.
More about this topic: LINK
EDIT:
FULL CODE SNIPPET:
.button {
display: inline-block;
padding-left: 68px;
padding-right: 20px;
height: 40px;
line-height: 40px;
font: 'Arial', Helvetica, sans-serif;
font-weight: 700;
font-size: 15px;
color: black;
text-decoration: none;
margin: 0px 0px 20px 10px;
position: relative;
}
.button .bar {
width: 1px;
height: 30px;
background: black;
position: absolute;
top: 5px;
left: 50px;
}
.button .arrow {
position: absolute;
left: 20px;
top: 11px;
}
.button .arrow .top {
position: absolute;
top: 0;
left: 3px;
width: 6px;
height: 9px;
background: #000;
}
.button .arrow .bottom {
position: absolute;
top: 9px;
left: -2px;
width: 0px;
height: 0px;
border-width: 8px;
border-style: solid;
border-color: black transparent transparent transparent;
}
.button:active{transform:translateY(10px)}
/* ---------- CSS3 ------------*/
.button {
border-radius: 3px;
box-shadow: 2px 2px 2px 0 rgba(0,0,0,.3);
transition: background-position .2s ease, margin .1s ease;
-webkit-transition: background-position .2s ease, margin .1s ease;
-moz-transition: background-position .2s ease, margin .1s ease;
background-repeat: repeat-x;
}
.button:hover {
background-position: 0 10px;
}
.blue {
background-color: #00aeef;
background-image: -webkit-linear-gradient(top, #00aeef, #00587a);
background-image: linear-gradient(top, #00aeef, #00587a);
text-shadow: 1px 1px 1px #23aaff;
border-top: 1px solid #23ccff;
}
.blue .bar {
box-shadow: 1px 1px 1px #23ccff;
}
.green {
background-color: #0f9;
background-image: -webkit-linear-gradient(top, #0f9, #060);
background-image: linear-gradient(top, #0f9, #060);
text-shadow: 1px 1px 1px #9f0;
border-top: 1px solid #23ccff;
}
.green .bar {
box-shadow: 1px 1px 1px #9f0;
}
<div id="container">
<a href="#" class="button blue">
<div class="arrow">
<div class="top"></div>
<div class="bottom"></div>
</div>
<div class="bar"></div>
Download
</a>
<a href="#" class="button green">
<div class="arrow">
<div class="top"></div>
<div class="bottom"></div>
</div>
<div class="bar"></div>
Download
</a>
</div>
Jakub Muda answer is better than mine in term of code, but to answer your exact question, that's because you add a margin to the clicked button, it pushes the container down, so both button move.
I modified your source https://codepen.io/anon/pen/RyVOyV and now they don't move together. The problem is that to get it, I had to make them position absolute.
.blue {
position:absolute;
top:15px;
}
.green {
position:absolute;
top:15px;
left:180px;
}
You can manipulate them more to get them positioned relative and independent, but that out of the scope of this question.
Hope it helps ;)
I can't remove grey "shadow" effect from input type button on half of it:
I checked all methods on forum but:
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
box-shadow: none;
outline: white;
doesn't work...
Excample:
.background {
background-color: lightgrey;
width: 400px;
height: 300px;
}
.button {
position: absolute;
left: 10px;
top: 10px;
background-color: black;
border-radius: 50%;
border-width: 2px;
border-color: white;
width: 25px;
height: 25px;
color: white;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
box-shadow: none;
outline: white;
}
.box {
position: absolute;
left: 20px;
top: 20px;
background-color: white;
width: 200px;
height: 100px;
}
<div class="background">
<div class="box">
</div>
<input type="button" class="button" value="x">
</div>
Forum posting system force me to write something more because I have many codelines in post. But I don't know what can I write more? Everthing is on image and in code above. So I write what this forum doesn't like: "Thanks at all :-)"
It is because of the border-style in the input type="button".
The reason you have that grey shadow is because it is set to 'outset', change this to solid for it to remove it :)
.button {
background-color: black;
border-radius: 50%;
border-width: 2px;
border-color: white;
border-style: solid;
}
change yourborder-color to transparent to remove any color, and will cause your border to take the color of the background due to border-width attribute
.button {
background-color: black;
border-radius: 50%;
border-width: 2px;
border-color: transparent; /* NEW */
}
On the main page of my site there are 4 hyperlinks that I want to appear on every page in the same way. Except I want the link of the page I'm on to be the same color as when I put my mouse on it.
I thought I could get that with this code:
.navigation {
padding: 40px 0px;
position: relative;
text-align: center;
width: 100%;
font-size: 30px;
}
.navigation a {
background: black;
border: 1px solid grey;
border-radius: 7px;
color: white;
display: inline-block;
margin: 100px 35px;
padding: 14px;
text-decoration: none;
opacity: 0.75;
font-family: impact;
}
.navigation a:hover {
background: white;
border: 1px solid black;
color: black;
}
#contact {
background: white !important;
color: black !important;
}
<div class="navigation">
Mes productions
DJ
<a target="_blank" href="./CV.pdf">Mon CV</a>
<div id="contact">
Me contacter
</div>
</div>
Problem is that it keeps the black background color with white font color and it goes under the other links and not inline with them.
But I think that it's a bad practice to place the link in the "div" in this situation. You can simply register a class for the link and compose styles for this class.
.navigation {
padding: 40px 0px;
position: relative;
text-align: center;
width: 100%;
font-size: 30px;
}
.navigation a {
background: black;
border: 1px solid grey;
border-radius: 7px;
color: white;
display: inline-block;
margin: 100px 35px;
padding: 14px;
text-decoration: none;
opacity: 0.75;
font-family: impact;
}
.navigation a:hover {
background: white;
border: 1px solid black;
color: black;
}
#contact a {
background: white !important;
color: black !important;
}
<div class="navigation">
Mes productions
DJ
<a target="_blank" href="./CV.pdf">Mon CV</a>
<div id="contact">
Me contacter
</div>
</div>
The links were all horizontally aligned until i put one of them in it's own div to change it's color when i'm on the page it is linking to.
Now i can't get him to go back in line.
<div class="navigation">
Mes productions
DJ
<a target="_blank" href="./CV.pdf">Mon CV</a>
<div id="contact">
Me contacter
</div>
</div>
.navigation {
padding: 40px 0px;
position: relative;
text-align: center;
width: 100%;
font-size: 30px;
}
.navigation a {
background: black;
border: 1px solid grey;
border-radius: 7px;
color: white;
display: inline-block;
margin: 100px 35px;
padding: 14px;
text-decoration: none;
opacity: 0.75;
font-family: impact;
}
.navigation a:hover {
background: white;
border: 1px solid black;
color: black;
}
#contact a {
background: white !important;
color: black !important;
display: inline-block !important;
}
You need to set display: inline-block on #contact, not #contact a.
I'm working on my navigation and I've added an effect that when you hover over a link, a blue border is added to the bottom. It works, but the only problem I'm having is that when you hover over a link, the border pushes all the other elements on the page down 3 pixels (the size of the border).
If anyone could clue me in on how to fix this it would be greatly appreciated. Here's the relevent code:
HTML
<div id="nav" class="wrapper">
<div class="site-navigation">
About
Work
<div class="site-title">Noelle Devoe</div>
Blog
Contact
</div>
</div>
CSS
.wrapper{
width: 1000px;
background-color: rgb(255,255,255);
margin: 0 auto;
overflow: hidden;
}
.site-navigation {
text-align: center;
overflow:hidden;
}
.site-navigation a{
font-family: 'Arvo', serif, Georgia;
width: 125px;
float: left;
padding: 50px 0 50px 0;
letter-spacing: 4px;
text-transform: uppercase;
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
color: rgb(82,82,82);
}
.site-navigation a:hover{
font-weight: bold;
border-bottom: 3px solid rgb(4,141,195);
text-shadow: rgb(200, 200, 200) 1px 1px 0px;
}
One easy fix is to add a transparent border when the element isn't being hovered.
Add border-bottom: 3px solid transparent; to .site-navigation a.
.site-navigation a {
font-family:'Arvo', serif, Georgia;
width: 125px;
float: left;
padding: 50px 0 50px 0;
letter-spacing: 4px;
text-transform: uppercase;
-o-transition:.5s;
-ms-transition:.5s;
-moz-transition:.5s;
-webkit-transition:.5s;
transition:.5s;
color: rgb(82, 82, 82);
border-bottom: 3px solid transparent;
}
How about adding below CSS:
border-bottom: 3px solid transparent;
to
.site-navigation a
Simple way to solve the hover problem!
<div class="main">
<div class="box"></div>
</div>
.main{
height: 205px;
width: 405px;
}
.box{
height: 200px;
width: 400px;
border:1px solid rgb(0, 0, 0);
transition:
0.3s;
}
.box:hover{
margin-left: 5px;
margin-bottom: 5px;
box-shadow: -5px 5px black;
}