Triangle shape of anchor tag - css

I'm doing "interactive" menu with pure css , code :
<div class="holder">
<ul>
<li>one</li>
<li>two</li>
<li>three</li>
<li>four</li>
<li>five</li>
<li>six</li>
<li>seven</li>
<li>eight</li>
</ul>
</div>
*{
margin:0;
padding:0;
}
.holder{
position:fixed;
z-index: 10;
overflow:hidden;
left:6em;
width:26em;
height:26em;
border-radius:50%;
border:1px solid black;
}
.holder ul li{
position:absolute;
width:10em;
height:10em;
left: 50%;
top: 50%;
transform-origin: 100% 100%;
overflow: hidden;
border:1px solid black;
margin-left:-10em;
margin-top:-10em;
}
.holder ul li:nth-child(1){
-webkit-transform:rotate(0deg) skew(45deg)
}
.holder ul li:nth-child(2){
-webkit-transform:rotate(45deg) skew(45deg)
}
.holder ul li:nth-child(3){
-webkit-transform:rotate(90deg) skew(45deg)
}
.holder ul li:nth-child(4){
-webkit-transform:rotate(135deg) skew(45deg)
}
.holder ul li:nth-child(5){
-webkit-transform:rotate(180deg) skew(45deg)
}
.holder ul li:nth-child(6){
-webkit-transform:rotate(225deg) skew(45deg)
}
.holder ul li:nth-child(7){
-webkit-transform:rotate(270deg) skew(45deg)
}
.holder ul li:nth-child(8){
-webkit-transform:rotate(315deg) skew(45deg)
}
.holder ul li a{
display:block;
position:absolute;
-webkit-transform:skew(-45deg) rotate(-67.5deg);
width:14em;
height:14em;
border-radius: 50%;
bottom: -6.25em;
right: -6.25em;
text-decoration: none;
text-align:Center;
background-color:red;
font-size: 1.18em;
padding-top: 2.8em;
}
live demo : http://jsfiddle.net/Trolstover/n9bge484/8/
but it seems it isnt possible to fill that empty space next to anchor tag , to make it look like triangle (a.k.a slice of pizza)
Is there any way how to reach that goal?

If all you are trying to do is create a downward triangle with pure CSS you can use the following snippet:
#triangle-down {
width: 0;
height: 0;
border-left: 50px solid transparent;
border-right: 50px solid transparent;
border-top: 100px solid red;
}
<div id="triangle-down"></div>
Additional CSS shapes can be found here: https://css-tricks.com/examples/ShapesOfCSS/
Edit: I may have misunderstood the original pizza-like question. I assumed you meant a downward triangle.
Instead it seems you want to simply fill in the white area with color. If that is correct you could do the following:
.holder{background:red;}

Try increasing the dimensions of the li and remove the border radius.
width:13em;
height:13em;
margin-left:-13em;
margin-top:-13em;
* {
margin: 0;
padding: 0;
}
.holder {
position: fixed;
z-index: 10;
overflow: hidden;
left: 6em;
width: 26em;
height: 26em;
border-radius: 50%;
border: 1px solid black;
}
.holder ul li {
position: absolute;
width: 13em;
height: 13em;
left: 50%;
top: 50%;
transform-origin: 100% 100%;
overflow: hidden;
border: 1px solid black;
margin-left: -13em;
margin-top: -13em;
}
.holder ul li:nth-child(1) {
-webkit-transform: rotate(0deg) skew(45deg)
}
.holder ul li:nth-child(2) {
-webkit-transform: rotate(45deg) skew(45deg)
}
.holder ul li:nth-child(3) {
-webkit-transform: rotate(90deg) skew(45deg)
}
.holder ul li:nth-child(4) {
-webkit-transform: rotate(135deg) skew(45deg)
}
.holder ul li:nth-child(5) {
-webkit-transform: rotate(180deg) skew(45deg)
}
.holder ul li:nth-child(6) {
-webkit-transform: rotate(225deg) skew(45deg)
}
.holder ul li:nth-child(7) {
-webkit-transform: rotate(270deg) skew(45deg)
}
.holder ul li:nth-child(8) {
-webkit-transform: rotate(315deg) skew(45deg)
}
.holder ul li a {
display: block;
position: absolute;
-webkit-transform: skew(-45deg) rotate(-67.5deg);
width: 14em;
height: 14em;
bottom: -6.25em;
right: -6.25em;
text-decoration: none;
text-align: Center;
background-color: red;
font-size: 1.18em;
padding-top: 2.8em;
}
<div class="holder">
<ul>
<li>one
</li>
<li>two
</li>
<li>three
</li>
<li>four
</li>
<li>five
</li>
<li>six
</li>
<li>seven
</li>
<li>eight
</li>
</ul>

Related

menu of li:nth-child() color formatting

I have a menu containing of ul li items. I have five items, using flexbox to align them with the last item using margin-left:auto; to push it to the right.
I am also using transform: skewX(45deg) to create arrows for each li::before and li::after and I have a starting background-color. The arrow border is set to yellow.
My problem is that I would like to individually set the color for each li item, except the last li.
So, I would like to use li:nt-child property and set the background color and also take into account for before and after values.
I am guessing I need also to use the z-index maybe so the previous before and after color values are handled in a proper way.
This is my html code:
<nav class="flex-nav" id="nav">
<ul>
<li>Home page</li>
<li>Test page</li>
<li>Link1</li>
<li>Link2</li>
<li>Login</li>
</ul>
</nav>
And this is my css:
.flex-nav ul {
display: flex;
list-style-type: none;
padding-left: 0;
white-space: nowrap;
}
.flex-nav ul li {
justify-content: space-between;
align-items: center;
opacity: 1.0;
transition: opacity .2s ease-in-out;
position: relative;
line-height: 26px;
margin: 0 9px 0 -10px;
padding: 0 20px;
}
ul li::before,
ul li::after {
border-right: 4px solid yellow;
content: '';
display: block;
height: 50%;
position: absolute;
left: 0;
right: 0;
top: 0;
z-index: -1;
transform: skewX(45deg);
background-color: #b0e0e6;
}
ul li::after {
bottom: 0;
top: auto;
transform: skewX(-45deg);
}
ul li:last-of-type::before,
ul li:last-of-type::after {
display: none;
}
ul li a {
font: bold 18px Sans-Serif;
letter-spacing: -1px;
text-decoration: none;
}
ul>li:hover {
opacity: 1.0;
}
ul:hover>li:not(:hover) {
opacity: 0.5;
}
.flex-nav ul li:last-child {
margin-left: auto;
}
Thanks :)
Try below CSS for change the background color for first, second and third items. Thanks
.flex-nav ul {
display: flex;
list-style-type: none;
padding-left: 0;
white-space: nowrap;
}
.flex-nav ul li {
justify-content: space-between;
align-items: center;
opacity: 1.0;
transition: opacity .2s ease-in-out;
position: relative;
line-height: 26px;
margin: 0 9px 0 -10px;
padding: 0 20px;
}
.flex-nav li:before,
.flex-nav li:after {
border-right: 4px solid yellow;
content: '';
display: block;
height: 50%;
position: absolute;
left: 0;
right: 0;
top: 0;
z-index: -1;
transform: skewX(45deg);
}
.flex-nav li:first-child::before,
.flex-nav li:first-child::after {
background-color: red;
}
.flex-nav li:nth-child(2)::before,
.flex-nav li:nth-child(2)::after {
background-color: green;
}
.flex-nav li:nth-child(3)::before,
.flex-nav li:nth-child(3)::after {
background-color: blue;
}
<nav class="flex-nav" id="nav">
<ul>
<li>Home page</li>
<li>Test page</li>
<li>Link1</li>
<li>Link2</li>
<li>Login</li>
</ul>
</nav>

li:hover>a affecting other list items

What I am trying to do is to get the hover effect that puts the anchor link a bit down, but somehow it affects all the links. Can somebody point out what I did wrong here?
nav {
width: 100%;
height: 5rem;
background: red;
}
ul {
margin: 0 auto;
font-size: 0;
}
ul li {
display: inline-block;
line-height: 4.8rem;
position: relative;
}
ul li > a {
text-decoration: none;
color: #FFF;
font-family: "Verdana";
padding: .1rem 1.5rem;
font-size: 1.3rem;
display: block;
overflow: hidden;
position: relative;
transition: 300ms all;
height: 100%;
margin: 0;
}
ul li > a::before, ul li > a::after {
content: '';
width: 100%;
position: absolute;
left: 0;
transition: 200ms all;
}
ul li > a::before {
background: #FFF;
height: .5rem;
top: 0;
transform: translateY(-100%);
}
ul li > a::after {
background: #000;
height: .4rem;
bottom: 0;
transform: translateY(100%);
}
ul li::before {
content: '';
width: 100%;
height: 100%;
top: 0;
left: 0;
background: #CCC;
position: absolute;
opacity: 0;
}
ul li:hover > a {
padding-top: 0.6rem;
padding-bottom: 0.1rem;
}
ul li:hover > a::before, ul li:hover > a::after {
transform: translateY(0);
}
ul li:hover::before {
opacity: 0.3;
}
<nav>
<ul>
<li>Link1</li>
<li>Link2</li>
<li>Link3</li>
<li>Link4</li>
<li>Link5</li>
</ul>
</nav>
Why li:hover > a is affecting all list items?
The problem is not your :hover selector, it's the display-block on the lis. inline-blockelements align on the baseline, this means that when you add a padding-topto one of them, all the others move down as well. To fix it float the elements to the left to keep them on one line and aligned to the top:
Demo: https://jsfiddle.net/403zexop/
nav {
width:100%;
height:5rem;
background:red;
}
ul {
margin:0 auto;
font-size:0;
overflow: hidden;
li {
display:block;
line-height:4.8rem;
position:relative;
float: left;
>a{
text-decoration:none;
color:#FFF;
font-family:"Verdana";
padding:.1rem 1.5rem;
font-size:1.3rem;
display:block;
overflow:hidden;
position:relative;
transition:300ms all;
height:100%;
margin:0;
&::before,&::after{
content:'';
width:100%;
position:absolute;
left:0;
transition:200ms all;
}
&::before{
background:#FFF;
height:.5rem;
top:0;
transform:translateY(-100%);
}
&::after{
background:#000;
height:.4rem;
bottom:0;
transform:translateY(100%);
}
}
&::before{
content:'';
width:100%;
height:100%;
top:0;
left:0;
background:#CCC;
position:absolute;
opacity:0;
}
&:hover{
>a{
padding-top:0.6rem;
padding-bottom:0.1rem;
&::before,&::after{
transform:translateY(0);
}
}
&::before{
opacity:0.3;
}
}
}
}
Note: I cleared the floats by adding overflow: hidden; to the ul
"li:hover > a" is correct!
The problem is, that with changing the padding you alter the height of the element, and the parent container has to adapt and as well all other childs.
You can see it when you do not change the padding, but just the background-color of the hovered a. You will see, it is just altering the current element.

I can't change size and position after hover of drop-down menu

I have problem with my drop-down menu. I don't know how to change position of buttons after scrolling under line to center position. Could you help me please?Thanks!
Example:
enter image description here
* {margin: 0; padding: 0;}
body {
font-family: arial;
color:#ccc;
}
#full-screen-background-image {
z-index: -999;
min-height: absolute;
min-width: absolute;
width: 100%;
position: fixed;
top: 0;
left: 0;
}
#wrapper {
min-height: 100%; _height: 100;
margin: 0 auto -150px auto;
}
a:hover {
color: #0095cd;
}
section {
background: url(/Users/ivanazuskinova/Dropbox/auttalk/INDEX/menu01.png)50% 0 no-repeat;
background-size: 1900px 86px;
opacity:0.8;
}
#header-content {
width:960px;
margin: 0 auto;
padding: 60px 0;
}
#content {
width: 960px;
margin: 0 auto;
padding: 100px 0;
}
.static {
width: 960px;
margin: 0 auto;
text-align: center;
position: relative;
}
nav li{
display: inline-block;
padding: 35px 60px 100px 0px;
}
nav li:nth-child(3) {
padding-right: 200px;
}
nav li:nth-child(1) {
padding-left: 4in 0px;
}
.static a {
transition: all linear 0.15s;
color: white;
}
.static li:hover > a,
.static .current-item > a {
text-decoration: none;
color: white;
}
.static .highlighted {
font-size: 10px;
line-height: 0%;
}
.static li:hover .dynamic {
z-index: 10;
opacity: 1;
}
.dynamic {
position: absolute;
z-index: 0;
opacity: 0;
transition: opacity linear 0.15s;
background: #ccc;
}
.dynamic li {
display: relative;
font-size: 14px;
}
.dynamic li a {
text-decoration: none;
color:#17177e;
}
.logo {
background: url(/Users/ivanazuskinova/Dropbox/auttalk/INDEX/logo.png) 50% 0 no-repeat;
background-size: 125px 86px;
height:155px;
width:180px;
position: absolute;
top: 2px;
left: 390px;
}
<section>
<header>
<div id="wrapper">
<div id="header">
<div class="static-wrap">
<div class="static">
<nav>
<ul>
<li>Home</li>
<li>o vás
<ul class="dynamic">
<li> <span class="highlighted">►</span>Vaše přiběhy</li>
<li><span class="highlighted">►</span>Diskusní fórum
</li>
</ul>
</li>
<li>Services</li>
<li>Work</li>
<li>Blog</li>
<li>Kontakt</li>
</ul>
</nav>
<div class="logo"></div>
</header>
</section>
Try adding a block display to the li links.
.dynamic li a {
display: block;
text-decoration: none;
color:#17177e;
}
Your
.dynamic li {
display: relative;
font-size: 14px;
}
add in 'display: block' in here so it looks like...
.dynamic li {
display: block;
font-size: 14px;
}

Drop down menu positioning

so I'm having this issue. Here is the jsfiddle.
https://jsfiddle.net/g5yo9jts/
<body>
<div class="header">
<div class="menuIcon">
<a id="nav-toggle" href="#menuExpand"><span></span></a>
<div class="box"><h3>Home</h3></div>
</div>
<div class="menu">
<ul>
<li>Menu Option 1</li>
<li>Menu Option 2</li>
<li>Menu Option 3</li>
<li>Menu Option 4</li>
</ul>
</div>
</div>
</body>
* {
-webkit-font-smoothing:antialiased;
padding: 0;
margin: 0;
}
#nav-toggle span {
margin-left: 15px;
float: left;
}
#nav-toggle span, #nav-toggle span:before, #nav-toggle span:after {
cursor: pointer;
border-radius: 1px;
height: 3px;
width: 25px;
background: white;
position: absolute;
display: block;
content: '';
}
#nav-toggle span:before {
top: -6px;
}
#nav-toggle span:after {
bottom: -6px;
}
#nav-toggle span, #nav-toggle span:before, #nav-toggle span:after {
transition: all 500ms ease-in-out;
}
#nav-toggle.active span {
background-color: transparent;
}
#nav-toggle.active span:before, #nav-toggle.active span:after {
top: 0;
}
#nav-toggle.active span:before {
transform: rotate(45deg);
}
#nav-toggle.active span:after {
transform: rotate(-45deg);
}
h3 {
font-size: 1em;
color: white;
float: right;
margin-right: 15px;
margin-bottom: 25px;
font-family: "alternate-gothic-no-3-d";
font-weight: 800;
}
.header .menu ul {
padding: 0;
margin: 0;
}
.header .menu ul li {
display: inline-block;
list-style: none;
padding: 0 0 0 5px;
margin: 0;
}
.header .menuIcon {
height: 50px;
display: none;
background: #000;
width: 100%;
}
.header .menuIcon a {
width: 100%;
display: inline-block;
color: #fff;
}
.header .menuIcon a img {
vertical-align: middle;
}
#media only screen and (min-width: 400px) {
.menu {
display: none;
}
}
#media only screen and (max-width: 767px) {
.header .menu {
max-height: 0;
overflow: hidden;
float: none;
text-align: center;
width: 100%;
-webkit-transition: max-height 0.5s;
-moz-transition: max-height 0.5s;
transition: max-height 0.5s;
}
.header .menu.menuOpen {
max-height: 1000px;
-webkit-transition: max-height 0.5s;
-moz-transition: max-height 0.5s;
transition: max-height 0.5s;
}
.header .menu ul li {
display: block;
width: 100%;
background: #000;
border-top: 1px solid #4d4d4d;
}
.header .menu ul li:hover {
background: #999;
}
.header .menu ul li a {
color: #fff;
text-shadow: #848484 0px 1px 2px;
padding: 10px;
width: 100%;
}
.header .menuIcon {
display: inline-block;
}
}
$(function() { $("a[href=#menuExpand]").click(function(e) {
$(".menu").toggleClass("menuOpen"); e.preventDefault(); });});
document.querySelector( "#nav-toggle" ).addEventListener( "click",
function(){
this.classList.toggle( "active" );
});
$(".header").click(function() {
$('.menu').show();
});
The main issue is my hamburger icon and text font aren't lining up. As you can see the hamburger is centered vertically and the text is on bottom right. I've tried everything from margining the text, to adding a box div to the text to move it. Floating, absolute positioning is not working.
I'd also like to have the hamburger icon on the right, and the text for my page on the left but I was having issues with the centering that I hadn't got that far. If anybody could help out that would be awesome.
Thanks so much.
NB: Resize the fiddle 'Result' view to something closer to a mobile/tablet device display resolution to view the menu. Maximum width 767px.
I think i have your problem solved. Only thing is there is a small gap between the header and the menu items when the menu appears (didn't tackle that) I'm sure some negative padding/margin will fix that right up
$(function() {
$("a[href=#menuExpand]").click(function(e) {
$(".menu").toggleClass("menuOpen");
e.preventDefault();
});
});
document.querySelector("#nav-toggle").addEventListener("click", function() {
this.classList.toggle("active");
});
$(".header").click(function() {
$('.menu').show();
});
$(".swap").click(function() {
var _this = $(this);
var current = _this.attr("src");
var swap = _this.attr("data-swap");
_this.attr('src', swap).attr("data-swap", current);
});
* {
-webkit-font-smoothing: antialiased;
padding: 0;
margin: 0;
}
.menuIcon a,
.menuIcon p {
display: inline;
}
#nav-toggle span {
margin-left: 15px;
float: left;
}
#nav-toggle span,
#nav-toggle span:before,
#nav-toggle span:after {
cursor: pointer;
border-radius: 1px;
height: 3px;
width: 25px;
background: #000000;
position: absolute;
display: block;
content: '';
}
/*#nav-toggle span:before {
top: -6px;
}
#nav-toggle span:after {
bottom: -6px;
}*/
#nav-toggle img,
#nav-toggle img:before,
#nav-toggle img:after {
transition: all 500ms ease-in-out;
}
#nav-toggle.active img:before,
#nav-toggle.active img:after {
top: 0;
}
#nav-toggle.active img:before {
transform: rotate(45deg);
}
#nav-toggle.active img:after {
transform: rotate(-45deg);
}
h3 {
font-size: 1em;
color: white;
float: left;
margin-left: 15px;
padding-top: 15px;
font-family: "alternate-gothic-no-3-d";
font-weight: 800;
}
.header .menu ul {
padding: 0;
margin: 0;
}
.header .menu ul li {
display: inline-block;
list-style: none;
padding: 0 0 0 5px;
margin: 0;
}
.header .menuIcon {
height: 50px;
display: none;
background: #000;
width: 100%;
}
.header .menuIcon a {
width: 100%;
display: inline-block;
color: #fff;
}
.header .menuIcon a img {
width: 75px;
height: 50px;
float: right;
margin-top: -34px;
margin-bottom: 15px;
}
#media only screen and (min-width: 400px) {
.menu {
display: none;
}
}
#media only screen and (max-width: 767px) {
.header .menu {
max-height: 0;
overflow: hidden;
float: none;
text-align: center;
width: 100%;
-webkit-transition: max-height 0.5s;
-moz-transition: max-height 0.5s;
transition: max-height 0.5s;
}
.header .menu.menuOpen {
max-height: 1000px;
-webkit-transition: max-height 0.5s;
-moz-transition: max-height 0.5s;
transition: max-height 0.5s;
}
.header .menu ul li {
display: block;
width: 100%;
background: #000;
border-top: 1px solid #4d4d4d;
}
.header .menu ul li:hover {
background: #999;
}
.header .menu ul li a {
color: #fff;
text-shadow: #848484 0px 1px 2px;
padding: 10px;
width: 100%;
}
.header .menuIcon {
display: inline-block;
}
}
<body>
<div class="header">
<div class="menuIcon">
<p>
<h3>ELIJi</h3>
</p>
<a id="nav-toggle" href="#menuExpand">
<img class="swap" src="http://www.rachelgallen.com/images/hamburgerIcon.png" data-swap="http://www.rachelgallen.com/images/close.png"></img>
</a>
</div>
<div class="menu">
<ul>
<li>Menu Option 1
</li>
<li>Menu Option 2
</li>
<li>Menu Option 3
</li>
<li>Menu Option 4
</li>
</ul>
</div>
</div>
</body>

Imposing ul li menu items

I want to make an ul li menu and I want to place each li element over previous one.
I don't know if I can explain with words what I mean, so I've made an image showing desired effect:
How can I do this using plain CSS? Is it possible, or I must use javascript?
This is what I've tried so far:
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
position: relative;
}
li a {
display: block;
position: absolute;
top: -30px;
z-index: 1;
width: 225px;
height: 115px;
}
but each li appears on the same place over previous one.
You can use a negative margin-top to "lift" the li elements.
http://jsfiddle.net/tomprogramming/mbe9W/
relevant CSS
li { padding:10px; border:1px solid #000; margin-top:-10px; }
li:first-of-type {
margin-top:0;
}
​
I think this is close:
​<ul>
<li><a class="a" href="#">A</a></li>
<li><a class="b" href="#">B</a></li>
<li><a class="c" href="#">C</a></li>
</ul>
​
CSS:
ul {
margin: 0;
padding: 0;
list-style: none;
padding-top:30px;
}
li {
position: relative;
height:50px;
}
li a {
display: block;
position: absolute;
height:20px;
top: -30px;
left:0;
width:225px;
height:115px;
}
.a {
border:1px solid #ff0000
}
.b {
border:1px solid #00ff00
}
.c {
border:1px solid #ffff00
}
​

Resources