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

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.

Related

Put text on the same line with button

I'm trying to put the text with button on right on the same level but for some reason it doesn't show up correctly. What am I doing wrong?
.lyrics {
margin: 20px 0;
}
.lyrics a {
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics a:hover {
text-decoration: none;
color: black;
background: #f0d0b5;
}
lyric-align {
display: inline-block;
margin: 0;
}
Song Title <div class="lyrics">Lyrics
Just write html like this:
<div class="lyrics">Song Title Lyrics</div>
And css like this:
.lyrics {
margin: 20px 0;
}
.lyrics a {
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics a:hover {
color: black;
background: #f0d0b5;
text-decoration: none;
}
And because now you have one div, you can move him where you want. If you want to have a wonder size not across the entire page, but just around the text, use:
.lyrics{
width: fit-content;
width: -moz-fit-content;
}
My recommended solution
I think the best solution would be to do it without DIV, leave only the "a" element there and style it like this. But I don't know what part of the page you didn't show.
HTML
Song Title Lyrics
CSS
.lyrics {
margin: 20px 0;
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics:hover {
text-decoration: none;
color: black;
background: #f0d0b5;
}
Couple of things I see in your code:
A div is a block element, it's going to take up the whole page horizontally where it is placed.
The button is there, you can see it if you hover over the space below the text Song Title. But you don't have a closing tag for the first tag.
Extra Credit
Your CSS for your class lyric-align is missing a dot in front of the class's identifier.
Does this work for you?
I think you want the lyrics to be inline .
.lyrics {
margin: 20px 0;
}
.lyrics a {
color: white;
padding: 10px 16px;
border: 1px solid white;
font-size: 11px;
letter-spacing: 2px;
}
.lyrics a:hover {
text-decoration: none;
color: black;
background: #f0d0b5;
}
lyric-align {
display: inline-block;
margin: 0;
}
.lyrics {
display:inline;
}
.song-title {
display:inline;
}
<p class="song-title">Song Title </p><a class="lyrics" href="#">Lyrics</a></div>
If you want a button instead of the link, view this link.

CSS button does not highlight properly

I have this button which doesn't highlight properly when I click on it, please see the image, and CSS file down below
CSS for the toggle button:
.mat-button-toggle {
box-sizing: border-box;
height: 33px;
width: 159px;
border: 1px solid #E1E1E1;
border-radius: 2px;
background-color: #FFFFFF;
}
.mat-button-toggle:hover {
border: 1px #000 solid !important;
background-color: #FFF !important;
border-radius: 5px !important;
}
CSS for the text
.ticket {
margin-top: 5px;;
height: 18px;
width: 122px;
color: #111111;
font-family: Arial;
font-size: 16px;
letter-spacing: 0;
line-height: 18px;
}
HTML
<mat-button-toggle-group name="fontStyle" aria-label="Font Style" >
<mat-button-toggle routerLink="ticketView" value="ticketView">
<div class="ticket" id="p1">
{{'TicketOverView' | translate}}
</div>
</mat-button-toggle>
My guess is there is something else in your css html going on. I have recreated your css in codepen for you and couldn't reproduce your results.
I would double check your html markup.
Here is the codepen I produced
https://codepen.io/jmllr89/pen/KKdzLGw
Also you do not need !important on the :hover pseudo-class. CSS is smart enough to recognize what needs to be changed. So simply define your initial state in mat-button-toggle and then in mat-button-toggle:hover you create a second state, and css will make the necessary changes.
.mat-button-toggle {
height: 33px;
width: 159px;
border: 1px solid #E1E1E1;
border-radius: 2px;
background-color: #FFFFFF;
}
.mat-button-toggle:hover {
border-color: #000;
border-radius: 5px;
}

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/

btns (as anchor tags) not at same height but is side by side

Ok, I have two buttons that need to sit side by side. I got that. But the right 'button' is sitting higher than the left one. Why? I believe that it is because of my right 'button' has two lines of text with it. My proponent will not budge on this button having two lines of text. Does anyone know how to do this better?
I put my code in jsfiddle: http://jsfiddle.net/energeticpixels/k7awcfts/
Here is my code:
<div id='tonyzBTNs'>
<a id='regCourse' class='btn' href='https://cloudlms.slhc.serco-na.com' target='_blank'>Register for Course</a>
<a id='regTest' class='btn' href='https://www.atrrs.army.mil/atrrscc/courseInfo.aspx?fy=2016&sch=910&crs=4E-F33%2f645-F17+(DL)&crstitle=ARMY+ELECTRICAL+EXPLOSIVE+SAFETY+(CERT)&phase=' target='_blank'>Register for Exam<span style="font-size: 10px;"><br />(after completing the course)</span></a>
</div>
And the css:
#tonyzBTNs {
margin-top: 20px;
margin-bottom: 20px;
}
#tonyzBTNs .btn {
text-align: center;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 18px;
font-weight: bold;
text-decoration: none;
}
#tonyzBTNs #regCourse {
background-color: #9EB95C;
border: 2px solid #708542;
border-radius: 10px;
padding: 10px;
color: black;
}
#tonyzBTNs #regTest {
background-color: #C54F4D;
border: 2px solid #6A4346;
border-radius: 10px;
padding: 1px 10px 1px 10px;
color: white;
display: inline-block;
}
Depending on how the rest of the site is layed out, Using float: left; in your #tonyzBTNs #regCourse will probably solve your issue.
Updated Fiddle
#tonyzBTNs .btn {
...
vertical-align: top;
display: inline-block;
}
Demo

HTML/CSS link doesn't work probably

I have 3 links in my code but only two are working probably, why?
<div id="welcome-text-2" class="welcome-text">
<p>
<b>boldtext</b><br>
text link.<br>
Texthär.<br>
TextLink.<br>
</p>
</div>
CSS:
.welcome-text {
height: 240px;
width: 360px;
background-color: #FFF;
margin-left: 40px;
position: absolute;
-webkit-box-shadow: 0px 8px 6px -5px black;
}
#welcome-text-2 {
margin-top: 400px;
}
#welcome-text-2 b {
position: absolute;
margin-left: 10px;
margin-top: -10px;
}
#welcome-text-2 p {
position: absolute;
margin-top: 10px;
margin-left: 7px;
}
.welcome-text a {
text-decoration: none;
font-weight: bold;
color: #444;
}
.welcome-text a:hover {
text-decoration: underline;
font-weight: normal;
}
the last two links work when :hover'd. But the first one doesn't. I also tried to add a link in the first row but it didn't appear.
I assume that you are beginning to learn HTML/ CSS.
The markup above works correct. Did you clear the browser-cache? There could old styles/ markup beeing cached.
http://www.wikihow.com/Clear-Your-Browser's-Cache
The Code Provided does work.
Adding onto what #ilovemondays said, Please make sure your links are updated if your stylesheet is external.