css triangles missing the tip - html

The left arrows displayed next to each carousel block div are missing the tip, unsure what else in the css is required to make it a complete triangle.
Live URL: http://bit.ly/1e5wZWQ (next to the large image. the information carousel)
HTML
<ul id="index-controls">
<li><div id="one" class="active indexcarouselcontrol">FREE DISC Profile</div>
<ul>
<li><h2>Training that fits like a glove</h2></li>
<li><p>Your company is as individual as the people it employs; and as such, it’s likely that your training requirements don’t tick any one, particular box. You may currently have a personnel issue that requires urgent attention. Or, you are taking a serious look at the management strategies you use to run your organisation and are considering an overhaul.</p></li>
</ul>
</li>
<li><div id="two" class="indexcarouselcontrol">Last Minute Availability</div>
<ul>
<li><h2>Training that fits like a glove</h2></li>
<li><p>Your company is as individual as the people it employs; and as such, it’s likely that your training requirements don’t tick any one, particular box. You may currently have a personnel issue that requires urgent attention. Or, you are taking a serious look at the management strategies you use to run your organisation and are considering an overhaul.</p></li>
</ul>
</li>
<li><div id="three" class="indexcarouselcontrol">Bespoke Training</div>
<ul>
<li><h2>Training that fits like a glove</h2></li>
<li><p>Your company is as individual as the people it employs; and as such, it’s likely that your training requirements don’t tick any one, particular box. You may currently have a personnel issue that requires urgent attention. Or, you are taking a serious look at the management strategies you use to run your organisation and are considering an overhaul.</p></li>
</ul>
</li>
</ul>
CSS
#index-controls div { display: block; background-color: #222424; font-weight: bold; margin: 0px; cursor: pointer; padding: 19px 20px 20px 20px; border-bottom: 1px solid #47839C; color: #fff; font-size: 1.1em; }
#index-controls div:before {
content: ' ';
position: absolute;
top: 100%;
left: -45px;
position: relative;
width: 0;
height: 0;
border-top: 19px solid transparent;
border-bottom: 20px solid transparent;
border-right: 25px solid #47839C;
}

The :before pseudo element give position:absolute and the parent of :before #index-controls div give position:relative and set top and left value as your need
try this:
#index-controls div {
display: block;
background-color: #222424;
font-weight: bold;
margin: 0px;
position: relative;
cursor: pointer;
padding: 19px 20px 20px 20px;
border-bottom: 1px solid #47839C;
color: #fff;
font-size: 1.1em;
}
#index-controls .active:before {
content: ' ';
position: absolute;
top: 0px;
left: -25px;
width: 0px;
height: 0px;
border-top: 19px solid transparent;
border-bottom: 20px solid transparent;
border-right: 25px solid #47839C;
}

Notice in your CSS you are overriding the absolute position with a relative position declaration.
The :before pseudo-element should be positioned absolutely to the relatively positioned div.
Then the CSS should be amended to:
media="screen"
#index-controls .active:before {
content: ' ';
position: absolute;
top: 0%;
left: -27px;
width: -0px;
height: 0px;
border-top: 27px solid transparent;
border-bottom: 27px solid transparent;
border-right: 27px solid #47839C;
}
The 27px is required because the div height is 54px (incluing padding).

Change font-size to 0em. See below:
#index-controls div {
display: block;
background-color: #222424;
font-weight: bold;
margin: 0px;
cursor: pointer;
padding: 19px 20px 20px 20px;
border-bottom: 1px solid #47839C;
color: #fff;
font-size: 0em;
}

Related

CSS 3 special rounded border [duplicate]

This question already has answers here:
Invert rounded corner in CSS?
(10 answers)
Closed last month.
I have tried to create that rounded border corners on the bottom but I can't figure it out how to make them ....
.test {
border-bottom: 2px solid #EEF7FF;
display: inline-flex;
}
.test li {
float: left;
list-style-type: none;
}
.test li a {
text-decoration: none;
padding-left: 30px;
padding-right: 30px;
padding-top: 5px;
color: #A6B5C7;
}
<div class="" style="margin-top: 20px;">
<ul class="test" style>
<li>
<a style="border-top: 2px solid #EEF7FF;border-left: 2px solid #EEF7FF;border-right: 2px solid #EEF7FF;border-bottom: 5px solid white;color: #000000 !important;padding-bottom: 5px;vertical-align: super;border-radius: 5px 5px 0px 0px; " href="">All</a>
</li>
<li>
Solved
</li>
</ul>
</div>
Connecting border-radius from adjacent elements
Those borders might be achieved connecting the borders of the adjacent list item elements.
After finishing the demo I realized it's not the best approach to get there actually. But since it shows how to deliver an idea I think it's still worth remaining here.
Styling the active item - border-left and border-top:
I added the class active to distinguish between active and inactive navigation links.
The item with the active has only the border left and top styled:
li.active a {
position: relative;
color: black;
vertical-align: super;
border-top: solid var(--border-size) var(--border-color);
border-left: solid var(--border-size) var(--border-color);
border-radius: var(--border-radius-active) var(--border-radius-active) 0px 0px;
}
Styling the active item - border-right:
While the right border gets styled using the pseudoelement ::after positioned absolute. The reason why we couldn't style directly the right border it's because its lenght can't be the whole height since we are trying to connect with this segment the border radius coming from two different elements and if we used the whole lenght it wouldn't look right:
li.active a::after {
content:"";
background: var(--border-color);
position: absolute;
bottom: var(--border-offset-bottom);
right: 0;
height: calc(100% - var(--border-offset-top) - var(--border-offset-bottom));
width: var(--border-size);
}
Styling the next item - border-bottom:
And eventually the last portion of the line is styled by the next element:
li.active + li a {
border-bottom: solid var(--border-color) var(--border-size);
border-radius: 0 0 0 var(--border-radius-inactive);
}
Custom properties:
I encoded the core parameters as custom properties in the :root element:
--border-color: #EEF7FF;
--border-size: 1px;
--border-offset-top: 4px;
--border-offset-bottom: 2px;
--border-radius-active: 10px;
--border-radius-inactive: 3px;
The demo:
In the demo you can toggle the border color to red to better see in contrast the result:
:root{
--border-color: #EEF7FF;
--border-size: 1px;
--border-offset-top: 4px;
--border-offset-bottom: 2px;
--border-radius-active: 10px;
--border-radius-inactive: 3px;
}
.red{
--border-color: red;
}
*{
box-sizing: border-box;
}
body{
font-size: 30px;
font-family: sans-serif;
}
.test {
display: inline-flex;
}
.test li {
float: left;
list-style-type: none;
}
.test li a{
text-decoration: none;
padding-left: 30px;
padding-right: 30px;
padding-top: 5px;
padding-bottom: 5px;
color: #A6B5C7;
}
li.active a {
position: relative;
color: black;
vertical-align: super;
border-top: solid var(--border-size) var(--border-color);
border-left: solid var(--border-size) var(--border-color);
border-radius: var(--border-radius-active) var(--border-radius-active) 0px 0px;
}
li.active a::after {
content:"";
background: var(--border-color);
position: absolute;
bottom: var(--border-offset-bottom);
right: 0;
height: calc(100% - var(--border-offset-top) - var(--border-offset-bottom));
width: var(--border-size);
}
li.active + li a {
border-bottom: solid var(--border-color) var(--border-size);
border-radius: 0 0 0 var(--border-radius-inactive);
}
button{
cursor: pointer;
padding: 1em;
}
<div style="margin-top: 20px;">
<ul id="nav" class="test" style>
<li class="active">
All
</li>
<li>
Solved
</li>
</ul>
</div>
<button onclick="document.getElementById('nav').classList.toggle('red')">change color to red!</button>

Align link bottom and right

I'm trying to move the green link so that it's sitting on the line like the span. This is my HTML
<div class="adminpanel-span" id="approved-users">
<span>Approved Users</span>
Download List
</div>
This is my CSS
.adminpanel-span {
font-size: 36px;
border-bottom: 1px solid #777777;
padding-bottom: 10px;
}
I've looked at other posts and found how to get it to the right, but I couldn't find how to bring it down to the line. How can you position the link on the line?
.adminpanel-span {
font-size: 36px;
border-bottom: 1px solid #777777;
padding-bottom: 10px;
position: relative;
}
.adminpanel-span > a{
position: absolute;
bottom: 0px;
right: 0px;
}
<div class="adminpanel-span" id="approved-users">
<span>Approved Users</span>
Download List
</div>
Try to use postion: absolute and position: relative

Attach event on pseudo-element

I'm trying to attach a click element only on the :after pseudo-element on the following fiddle:
<div class="tag deletable", style="style")>
Tagname
</div>
.tag {
display: inline-block;
background: white;
padding: 3px 6px;
line-height: 1em;
border-radius: 4px;
font-size: 12px;
border-right: 5px solid;
}
.deletable {
border-right: 18px solid;
position: relative;
}
.deletable:after {
content: "\D7";
position: absolute;
color: white;
right: -12px;
top: 3px;
font-size: 12px;
cursor: pointer;
}
https://jsfiddle.net/x2ztqdbm/
But it seems that is not possible. Is there a way to achieve that?
If not, can someone help me rewriting the HTML code in order to not use a pseudo-element? It's important that the :after section never breaks to the next line.
Thanks in advance.
Try This
HTML
<div class="tag deletable", style="style")>
Tagname
<span class="wrong">x</span>
</div>
CSS
.tag {
display: inline-block;
background: white;
padding: 3px 6px;
line-height: 1em;
border-radius: 4px;
font-size: 12px;
border-right: 5px solid;
}
.deletable {
border-right: 18px solid;
position: relative;
}
.wrong {
position: absolute;
color: white;
right: -12px;
top: 3px;
font-size: 12px;
cursor: pointer;
}
Preety much the same. use a font-awesome icon in place of 'x'
Link for reference
Pseudo elements (as far as I know) are not part of the DOM, so you can't attach events to them. However, why not using an inline element like a tag or something like that? It would be even easier...
You can attach a click event to a pseudo element using the pointer-events css-rule, like this: https://jsfiddle.net/cq9yzjeb/

CSS Pseudo Element Changes Height When Moving its Position

I'm creating tabs, where each link inside the tab list is in a div with a border - something like:
In order to hide the bottom border of the tabset below the selected tab, I'm adding a pseudo element (:after) that is the full width of the link, and whose height is the same as the bottom border (2px), and also has a bottom value of negative the border height (-2px). I'm running into an issue where, depending on the position (bottom value) of the pseudo element, its rendered height changes. If I set its height to 2px, it fluctuates between 1px and 2px, and does this every 2px when moving its position.
For example, at bottom: 3px, it looks like this (I've made the background red for illustration purposes):
But then if I set bottom: 2px, I get this:
I see this behavior on both firefox and chrome. Here's a codepen illustrating.
And here's an inline snippet of the same code:
.main-container {
padding: 50px;
font-family: arial;
}
.link-container {
display: inline-block;
border: 2px solid #000;
}
a {
position: relative;
display: block;
text-decoration: none;
font-weight: bold;
color: #000;
padding: 5px 5px 15px;
}
a:hover {
background: #ccc;
}
a:after {
content: "";
position: absolute;
z-index: 1;
height: 2px;
left: 0;
right: 0;
bottom: 2px;
background: red;
}
a.tab2:after {
bottom: 3px;
}
<div class="main-container">
<div class="link-container">
<a class="tab1" href="#">Test Tab</a>
</div>
<div class="link-container">
<a class="tab2" href="#">Test Tab</a>
</div>
</div>
What's going on?
I don't know if it's still relevant or not, but I run into the same problem and I couldn't find any solution online so I came up with my own - I think this problem related either with float size of the parent element, either with something else.
But adding "transform: scaleY(1.0001);" to your pseudo-element seems to work for me
.main-container {
padding: 50px;
font-family: arial;
}
.link-container {
display: inline-block;
border: 2px solid #000;
}
a {
position: relative;
display: block;
text-decoration: none;
font-weight: bold;
color: #000;
padding: 5px 5px 15px;
}
a:hover {
background: #ccc;
}
a:after {
content: "";
position: absolute;
z-index: 1;
height: 2px;
left: 0;
right: 0;
bottom: 2px;
background: red;
transform: scaleY(1.0001);
}
a.tab2:after {
bottom: 3px;
}
<div class="main-container">
<div class="link-container">
<a class="tab1" href="#">Test Tab</a>
</div>
<div class="link-container">
<a class="tab2" href="#">Test Tab</a>
</div>
</div>
Most likely your browser is zoomed in on the page. Make sure that you're viewing the page at 100% size by clicking ctrl + 0 and see if the height still changes with the position.
Other than that, if I understand correctly what you want to achieve, you're making things much more complicated than needed.
Firstly, unless you have a reason, the link-container divs are not needed. You can just put the links directly as childs of the main-container div and add borders to them directly.
Secondly, you can just use border-bottom and set it to whatever you like.
Why don't you just do it like this: Remove the pseudo element completely and reduce the border to three sides:
.link-container {
display: inline-block;
border-top: 2px solid #000;
border-left: 2px solid #000;
border-right: 2px solid #000;
}
Here it is in your snippet:
.main-container {
padding: 50px;
font-family: arial;
}
.link-container {
display: inline-block;
border-top: 2px solid #000;
border-left: 2px solid #000;
border-right: 2px solid #000;
}
a {
position: relative;
display: block;
text-decoration: none;
font-weight: bold;
color: #000;
padding: 5px 5px 15px;
}
a:hover {
background: #ccc;
}
<div class="main-container">
<div class="link-container">
<a class="tab1" href="#">Test Tab</a>
</div>
<div class="link-container">
<a class="tab2" href="#">Test Tab</a>
</div>
</div>

Difference of pixel in border I can't figure where it is coming from

Hi I'm doing a really simple navigator but I just came up into a strange problem I can't figure out where this is coming from.
My separations are not exactly till, they are created the same way..
Some are tougher than other and I don't get why.
Could it be due to the font ? I tried it with different browser and the problem is persistent...
JsFiddle There
The code is really simple :
HTML
<nav id="main-menu2">
<span class="fa fa-home"></span>
DERNIÈRES MINUTES
SÉJOURS
CROISIÈRES
CIRCUITS
FRANCE
WEEK-ENDS
VOYAGE À LA CARTE
PROMOS
</nav>
SCSS
$darkOrange: #ed6d00;
#main-menu2 {
background-color: $darkOrange;
width: 100%;
text-align: center;
font-size: 0.7em;
a{
color: #fff;
text-decoration: none;
border-left: 1px solid #fff;
border-right: 1px solid #fff;
margin-left: -2px;
margin-right: -2px;
padding-left: 10px;
padding-right: 10px;
font-size: 1.3em;
line-height: 1.7em;
}
.fa-home{
font-size: 23px;
position: relative;
top: 2px;
}
}
I can't reproduce the bug, but I may have a solution : you're currently using borders that you don't need. Let me explain : there is a border right on Séjours and a border left on Croisières. So 2 borders, and you're currently hiding one of them.
Using font-size in em, makes your trick (margin-left / margin-right : -2px) unconsistent, because em can't really be converted into px (well it can, but it will depends on the browser calculation so you may need more than 2px to make a border go over another, maybe 1px maybe 1.5487px).
So, my solution : removes all the unecessary borders :
a {
border-left: 1px solid #fff;
}
a:last-child {
border-right: 1px solid #fff;
}
No more borders overlapping, more reliable solution.
Manage it with the font-size:
#main-menu2 {
font-size: 0;
}
#main-menu2 a {
font-size: 14.5px;
margin-left: -1px;
margin-right: 0;
}
The whole code:
$darkOrange: #ed6d00;
#main-menu2 {
background-color: $darkOrange;
width: 100%;
text-align: center;
font-size: 0;
a{
color: #fff;
text-decoration: none;
border-left: 1px solid #fff;
border-right: 1px solid #fff;
margin-left: -1px;
padding-left: 10px;
padding-right: 10px;
font-size: 14.5px;
line-height: 1.7em;
}
.fa-home{
font-size: 23px;
position: relative;
top: 2px;
}
}
Demo: JSFiddle
It is because in your code you have some space by indent the text. Unfortunately all browsers interprete these content as white spaces and thus you have some gap between the elements.