CSS overflow:hidden creating margin at bottom - html

When I add
overflow:hidden
to any of the buttons on my page, it creates 13px of margin at the bottom of the button. When I remove the above CSS, the margin disappears, however some content inside the button overflows.
How can I remove the margin at the bottom, while keeping the
overflow:hidden
CSS style?
WITH overflow:hidden
WITHOUT overflow:hidden
, however, the Facebook logo overflows into the next button (it is a custom font)
CURRENT BUTTON CSS:
.btn {
background-color: #FF6347;
border: 1px solid #CC4F39;
color: #FFFFFF;
text-decoration: none;
padding: 7px 15px;
cursor: pointer;
font-size: 1em;
text-shadow: 0 1px 2px #000000;
display: inline-block;
overflow: hidden;
}
CURRENT BUTTON HTML:
<a class="btn btn-fb btn-xl" id="login_fb"><span class="icon-socialfacebookvariant"></span>Log In</a>
CURRENT FACEBOOK LOGO CSS:
[class^="icon-"], [class*=" icon-"] {
overflow:hidden;
}
[class^="icon-"]:before, [class*=" icon-"]:before {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size:2em;
line-height:0;
font-family: 'icomoon';
position:relative;
top:-1px;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
vertical-align:middle;
}
// Facebook logo from a font
.icon-socialfacebookvariant:before {
content: "\e9e3";
}

Thanks Jaunt for the help.
Although your idea is the most logical, it's not very nice when editing!
Luckily I happened to come across a simple fix to my problem!
All I had to do was add vertical-align:top to my button CSS, and wham! it works!
Thanks for your help :)

It's because you have white-spacing between the HTML elements. This snippet is with the white-spacing:
.btn {
background-color: #FF6347;
border: 1px solid #CC4F39;
color: #FFFFFF;
text-decoration: none;
padding: 7px 15px;
cursor: pointer;
font-size: 1em;
text-shadow: 0 1px 2px #000000;
display: inline-block;
overflow: hidden;
}
<div class="btn"></div>
<div class="btn"></div>
<div class="btn"></div>
<div class="btn"></div>
<div class="btn"></div>
And this one is without:
.btn {
background-color: #FF6347;
border: 1px solid #CC4F39;
color: #FFFFFF;
text-decoration: none;
padding: 7px 15px;
cursor: pointer;
font-size: 1em;
text-shadow: 0 1px 2px #000000;
display: inline-block;
overflow: hidden;
}
<div class="btn"></div><div class="btn"></div><div class="btn"></div><div class="btn"></div><div class="btn"></div>
There is a notable difference and I believe this is where your mysterious margin is coming from.

Related

Caret going next to text rather than the span on contenteditable div

When using the contenteditable attribute on a div and have inserted a HTML element span in, for some reason the caret goes inside the space next to the text:
To replicate, hit backspace to remove the question mark at the end on the example I provided
.pill {
background-color: #EEEEEE;
border: none;
color: black;
padding: 0px 4px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 4px 2px;
cursor: pointer;
border-radius: 5px;
font-weight: bold;
font-size:0.8em;
z-index:100;
}
<div style="resize:none; overflow: auto; border: none" contenteditable="true">
is your email still <span class="pill" contenteditable="false">Email</span>?
</div>

Set hover on the link inside a class

I'm trying to set a :hover for a link inside a class. At first I tried
.link{
color: #e62739;
}
I saw past discusssion and try the solution proposed
.opener a.link:hover {
color: #e62739;
}
but it didn't work. Im'not sure to know where is my mistake.
.link{text-decoration:none; color:white;}
.opener a.link:hover {
color: #e62739;
}
.row {
display: flex; /* equal height of the children */
}
.col {
flex: 1; /* additionally, equal width */
padding: 1em;
border: solid;
}
div {font-family:'Varela Round';
}
.opener {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
border: 1px white solid;
}
.benefits {
background-color: #07183d;
border: none;
color: white;
padding: 15px 32px;
text-decoration: none;
display: inline-block;
font-size: 16px;
width:300px;
}
a {
text-decoration: none;
}
#upbutton {
border: 1px dotted white;
}
<div class="row">
<div class="opener col" style="padding-left: 10px;padding-right: 10px;"><a class="link" href="www.google.com" name="1" onclick=" show('1');" style="color: white;font-size: 14px;">SOCIETES: 400</a>
<div class="benefits" id="b1" style="display: none; color: white; font-size: 14px;">Part SBF 120 : 120<br />
Part Filiales +100M€: 280
<div id="upbutton"><a onclick=" hide('1');">fermer</a></div>
</div>
</div>
The issue is the inline styling you've got on the link: color: white;.
This is taking priority over any styling you're adding in your CSS file. Removing that from the inline styling allows the hover color to work.
If you need the white color by default add it to the stylesheet rather than inline. For example:
.link {
color: white;
}

Can I achieve a scrollable flex container without a scrollbar on mobile devices using css only?

I uploaded a video here : https://streamable.com/uyddy
I am asking if I can somehow hide the horizontal scrollbar in that specific div, while still being able to scroll? I want to achieve this on mobile devices.
I attached the code here :
https://codepen.io/UrsuGrizzly/full/aVRZyg/
https://jsfiddle.net/o2ucuorL/
<div id="bottom">
All
Images
Videos
News
Maps
<a id="books" href="#">Books</a>
<a id="flights" href="#">Flights</a>
<a id="personal" href="#">Personal</a>
<a id="stools" href="#">Search tools</a>
<a id="moar" href="#">More</a>
Settings
<a href="#" id="tools">Tools</a
</div>
body{
font-family: arial,sans-serif;
font-size: 13px;
}
#bottom{
grid-area: 2/1/3/3;
display: flex;
overflow-x:scroll;
}
#bottom a{
font-size: 12px;
text-transform: uppercase;
text-decoration: none;
color: rgba(0,0,0,0.54);
padding: 14px 16px 12px 16px;
}
#bottom #stools{
border-left: 1px solid rgba(0,0,0,.12);
padding: 14px 16px 12px 24px;
white-space:nowrap;
}
#bottom #all{
color: #4285f4;
border-bottom: 2px solid #4285f4;
}
what I'd do is just to wrap the #bottom div inside a parent div with a fixed height and the overflow property set to hidden. Then you just have to give the #bottom div a padding-bottom with the same height as the scrollbar has (like 10px more or less). And thats all :), works great. Leave here the code:
// HTML Part
<div class="container">
<div id="bottom">
All
Images
Videos
News
Maps
<a id="books" href="#">Books</a>
<a id="flights" href="#">Flights</a>
<a id="personal" href="#">Personal</a>
<a id="stools" href="#">Search tools</a>
<a id="moar" href="#">More</a>
Settings
Tools
</div>
</div>
// CSS Part
body {
padding: 0;
margin: 0;
font-family: arial,sans-serif;
font-size: 13px;
}
.container {
height: 43px;
width: 100%;
overflow: hidden;
}
#bottom {
grid-area: 2/1/3/3;
display: flex;
overflow-x: scroll;
padding-bottom: 10px;
}
#bottom a {
font-size: 12px;
text-transform: uppercase;
text-decoration: none;
color: #0000008a;
padding: 14px 16px 12px 16px;
white-space: nowrap;
}
#bottom a#all {
color: #4285f4;
border-bottom: 2px solid #4285f4;
}

This div's border is a floating line instead of an actual border

I might be missing something basic. It's so simple:
.items {
float: left;
font-family: 'Arial', sans-serif;
text-decoration: none;
color: black;
font-size: 30px;
margin: 25px 30px 0px 0px;
}
.langswitch {
border: 3px solid #86D1DA;
border-radius: 5px;
}
<a href="#" class="langswitch">
<div class="items">Italiano</div>
</a>
jsFiddle
Moving the class from the anchor to the div will make it (the border) disappear all together.
Well, your <a class="lamgswitch"> does not have any content... The float: left; makes the <div class="items">float out of it...
So try to remove it, and replace it with display: inline-block;, as the div is a block component, and you placed it inside an inline component (a)...
.items {
display: inline-block;
font-family: 'Arial', sans-serif;
text-decoration: none;
color: black;
font-size: 30px;
margin: 25px 30px 0px 0px;
}
.langswitch {
border: 3px solid #86D1DA;
border-radius: 5px;
}
<a href="#" class="langswitch">
<div class="items">Italiano</div>
</a>
Place the <a> tag inside the <div> rather than the other way around.
.items{
float: left;
font-family: 'Arial', sans-serif;
text-decoration: none;
color: black;
font-size: 30px;
margin: 25px 30px 0px 0px ;
}
.langswitch{
border: 3px solid #86D1DA;
border-radius: 5px;
}
<div class="items">Italiano</div>
Hope this helps.
Technically, placing the <a> inside the <div> is the semantically correct way to do this as described in the other answer.
If you really HAVE to do it this way, you need to change the display of the <a> tag from inline to inline-block.

Custom radio button not visible in iOs Safari

I am using below mentions css to show cutom radio buttons
input[type=radio]{
display:none;
}
.radio-options label::before {
content: "\2b24";
color:#e2e2e2;
display: inline-block !important;
width: 17px;
height: 17px;
vertical-align:middle;
margin-right: 8px;
background-color: #fff;
border: 1px solid #e2e2e2;
border-radius: 8px;
font-size: 9px;
text-align: center;
text-shadow: 0px 0px 3px #fff;
font-family: monospace;
padding-top: 1.8px;
line-height: 10px;
cursor: pointer;
}
.radio-options label.active-radio::before {
content: "\2b24";
color: #f9b410;
background-color: #fff;
font-size: 9px;
text-align: center;
text-shadow: 0px 0px 3px #fff;
font-family: monospace;
margin-left: 0px;
padding-top: 1.8px;
line-height: 10px;
}
<div class="radio-options">
<div class="col-md-6 col-xs-6">
<input id="some_thing" type="radio" >
<label ng-class="{'active-radio':true}">Something</label >
</div>
</div>
In desktop browser it's working correctly and showing radio button as
But in safari iOs its not displaying anything
Any suggestions what could be possible cause ?
It is because of the Unicode symbol you use as a content. It doesn't seem to appear on iOS. If you change to "Black Circle" instead it will work. (Just increase the font-size to compensate the size.)
Unicode Black Circle symbol
Similar issue