I want the triangle shaped pointer to leave enough space between the parent and dropdown menu.
What I want is as below:
What I have done is as below:
CSS for the triangle
.sf-menu ul li:first-child a:after {
content: '';
position: absolute;
left: 40px;
top:-0.01px;
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #072438;
}
js fiddle:
http://jsfiddle.net/2athcwe9/
you just need to adjust your top values on the ul and the arrow:
.sf-menu ul li:first-child a:after {
content: '';
position: absolute;
left: 40px;
top:-10px; <-------
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #072438;
}
.sf-menu ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
top: 63px; <---------------------
left: 0;
z-index: 99999;
background-color: #2D2D2D;
border-bottom:none;
/* background-image: linear-gradient(#444, #111); */
/*-moz-border-radius: 5px;*/
/*border-radius: 5px;*/
}
FIDDLE
Let me explain something about absoluted elements that must be placed as dropdowns:
.sf-menu ul {top: 100%}
.sf-menu li a {/*height: auto*/}
.sf-menu ul li:first-child a:after {top: auto; bottom: 100%}
Example here: jsfiddle
1) You have an ul (children with position absolute) inside another ul.sf-menu (parent with position relative).
Your code have your children ul with a top with a fixed value of 35px; it caused that the children ul were overlapping ul parent.
2) To make your children ul to be automatically under the area of your ul parent, you don't have to use a fixed value, you can use top: 100% to make it move from top to bottom outside the area of the ul parent.
3) But for your particular case, your parent relative element has a border-bottom, so using: top:100% makes it overlap that area. Well in this situation you can alter the rule and use a custom value as 108% or any custom px value.
4) Your anchors have a fixed height, you can delete the height. But if for some reason you can't, you can override it with height: auto.
5) Now the problem of the arrow. Your arrow have a top with fixed value (top: -0.01px), you can fix it with another custom fixed value like -10px, -20px; but you can apply the same rule applied to children ul and make it automatically be on top outside of your element.
6) You can reset the value of top using top: auto, and then you can add a bottom: 100%. It will position your arrow from bottom 0 to bottom 100% over the top of your div relative. When you find any top, bottom, left, right that doesn't work as you expected, you can override any of them with auto.
Related
My goal is to prevent box-shadow from overlapping on top of nearby elements by using :before and z-index.
But the shadow is going underneath the container of the list item that casts it because of the z-index.
It works fine if its parent container is just the body.
Is there a workaround regarding this or should I change my HTML and CSS
HTML (PUG)
div#main
ul
li
li
li
CSS (Stylus)
#main
background-color lightyellow
height 300px
width 300px
ul
padding 10px
li
background-color lightblue
height 50px
width 50px
margin 10px
position relative
&::before
content ''
box-shadow 0px 0px 15px 20px rgba(0,0,0,0.5)
position absolute
top 0px
right 0px
bottom 0px
left 0px
z-index -1
you are using an absolutely positioned pseudo elements without setting position: relative to its parent, i.e. why its causing this type of issues also you haven't set some basic CSS rules for a better results as:
Code Snippet
html,
body {
margin: 0;
padding: 0;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
#main {
background-color: lightyellow;
height: 300px;
width: 300px;
}
ul {
padding: 10px;
margin: 0;
position: relative;
}
ul li {
background-color: lightblue;
height: 50px;
width: 50px;
margin: 10px;
position: relative;
overflow: hidden;
}
ul li::before {
content: '';
box-shadow: 0px 0px 15px 20px rgba(0, 0, 0, 0.5);
position: absolute;
top: 0px;
left: 0px;
display: inline-block;
width: 100%;
height: 1px;
}
<div id="main">
<ul>
<li>List01</li>
<li>List02</li>
<li>List03</li>
</ul>
</div>
I found an answer, I don't know if this is the best way to go
HTML (PUG)
ul
li
div.content
span All
li
div.content
span By
li
div.content
span Myself
li
div.content
span ANYMORE!!!
CSS (STYLUS)
body
margin 15px
ul
display inline-block
li
width 120px
height 50px
.content
background-color lightyellow
border 1px solid rgba(0,0,0,0.85)
widows 100%
height 100%
position relative
&::after
box-shadow 0px 0px 15px 5px rgba(0,0,0,0.5)
position absolute
top 0
right 0
left 0
bottom 0
content ''
z-index -1
span
position absolute
top 50%
left 50%
transform translate(-50%, -50%)
I'm trying to add a triangle before a div in navigationTable using css, but I cant correctly match it with a div element.
Here's code
tmp tmp tmp
How solve this problem?
edit:
second problem: how to make edges of triangle smooth?
Absolute positioned element will be relative to the next parent element with relative (or absolute) positioning.
.elem{
color: dodgerblue;
font-weight: bold;
padding: 10px 20px;
position:relative; //YOU NEED THIS LINE
}
.elem:hover:before {
display: inline-block;
content: "";
top:0; //YOU NEED THIS LINE
width: 0;
height: 0;
border-style: solid;
border-width: 10px 15px 10px 0;
border-color: transparent red transparent transparent;
left: -15px;
position: absolute;
border-top: 20px solid transparent;
border-bottom: 20px solid transparent;
}
So what did you need. You need(ed) .elem to be relative, so that .elem:before could be positioned relative to that. You've also "forgot" to set top property (to 0).
I am having a page which contains set of buttons at the footer(bottom). When I open the page for the first time I get the buttons as below:
Now, sometimes the first three buttons gets hidden and I get the page as :
I am not getting what could go wrong? Interestingly, when I inspect the button and change any property, the buttons get aligned immediately. Strange but true.
Code for li elements:
li
{
position: relative;
top: 7px;
left: 10px;
display: block;
float: left;
margin-right: 10px;
}
Now when I remove the position relative then it does not gets hidden but ya, it reaches the top of the page.
Something Like this
Update : I assume it is because of position:relative, can I change my code without position relative? Or with position:absolute?
Fiddle
Try this css:
.details .action-bottom {
height: 29px;
background: #739DDD;
border: 2px solid #01296E;
border-top: 1px solid #666;
margin: 0px 0 0 0;
}
.details .action-bottom ul {
list-style: none;
margin:0;
padding:0;
}
.details .action-bottom li {
display: inline-block !important;
float: left !important;
padding: 6px !important;
position: inherit;
}
Update Live
Here is a link to a set of navigation style:
http://tympanus.net/Development/ArrowNavigationStyles/
Please scroll down the page to the last style "Fill Path".
I want to change the position of the navigation arrows, pushing each of them more to the edge of the container.
In the line 924 of the component.css file, there is this rule:
.nav-fillpath a::before,
.nav-fillpath a::after,
.nav-fillpath .icon-wrap::before,
.nav-fillpath .icon-wrap::after {
position: absolute;
left: 50%;
width: 3px;
height: 50%;
background: #566475;
content: '';
-webkit-transition: -webkit-transform 0.3s;
transition: transform 0.3s;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
outline: 1px solid transparent; /* for FF */
}
Clearly, I should change the "left" property here for the arrows to move. But when I change it for instance to 80%, one arrow moves closer to the edge (which I want), while the other distances from its edge. How this rule should be edited for both arrow to be push closed to their adjacent edge?
Just decrease the width of .nav-fillpath a css class.
.nav-fillpath{
width: 100px; /* decrease this width */
/* other css properties */
}
To give the text some space from nav icons, give margin to sides to .nav-fillpath h3.
.nav-fillpath h3{
margin: 0px 30px; /* remove margin: 0px; */
}
You can chance right and left of .next and .prev:
nav a.next {
right: -35px;
}
nav a.prev {
left: -35px;
}
try this:
.nav-fillpath .prev { margin-left:-80px;}
I'm trying to follow this answer to left align numbers and text in an ordered list for a navigation menu:
Left align both list numbers and text
Except I have a border around the ordered list and I'd like the list to fit within the border but still be aligned properly. My problem is if the li content is long, it will overflow/overlap into the li item below it. For instance, this is my fiddler version of it:
http://jsfiddle.net/jimmyzaas/36ftkLLq/5/
code:
.fixedwidth{
width: 200px;
background-color: #eee;
}
.dinosaurs {
list-style-position: inside;
margin: 0;
padding: 0;
border: 1px solid #ccc;
width: auto;
}
.dinosaurs li{
position: relative;
border-bottom: 1px solid #ccc;
padding: 3px;
}
.dinosaurs li a {
position: absolute;
left: 30px;
}
How can I have the li auto adjust height to a, without overlapping each other while using absolute positioning? Any suggestions? I can set a fixed height for the li but that would make all other li content unnecessarily high.
.dinosaurs li {
position: relative;
border-bottom: 1px solid #ccc;
padding: 3px;
overflow-x: hidden;
//overflow-x: auto;
}
You can use overflow-x: hidden; or overflow-x: auto;
auto will cause scroll bars to appear while hidden just hides the overflow.