Element manipulation and overflow in divs (HTML) - css

This is the code implementation
http://codepen.io/anon/pen/emjLMJ
I dont understand why:
the hyperlinks are not aligned with the bar title
The dropdown button (black background) is outside of the main quickbar div
overflow only hides the parts overflowing but doesnt force it inside the main wrapping div.
HTML code
<div id='quick_bar' >
<div id='bar_title'>
<span>Check:</span>
</div>
<div id='left_bar' class='qbar'>
<a href="#" id='show_courts' class ='short_filter'>One</a>
<a href="#" id='show_clubs' class ='short_filter'>Two</a>
<a href="#" id='show_courts' class ='short_filter'>Three</a>
<a href="#" id='show_courts' class ='short_filter'>Four</a>
</div>
<div id='right_bar'>
<a href="#" id='hideSearchBtn'class='list-group-item'>
<span id='DownGly' class ='glyphicon glyphicon-chevron-down'>
</span>
<span id='UpGly' class ='glyphicon glyphicon-chevron-up' style="visibility: hidden;">
</span>
</a>
</div>
</div>
CSS Code
#quick_bar {
width:320px;
background-color: white;
height: 18px;
border-radius: 3px;
margin-top: 2px;
border: 1px solid;
border-color: #dbdbdb;
}
#left_bar a{
margin-left: 4px;
margin-right: 3px;
font-size: 11px;
height: 18px;
font-style: Arial;
font-weight: bold;
}
#bar_title {
float: left;
font-size: 11px;
font-style: Arial;
font-weight: bold;
margin-left: 4px;
}
#right_bar a {
color: black;
}
#right_bar {
height: 18px;
width: 10%;
float: right;
background-color: black;
}

I made a few changes to your codepen; http://codepen.io/anon/pen/VYBGqX
To start with I took your span out of its own separate div, and removed the height from bar_title, which fixed your vertical alignment issues.
<div id='left_bar' class='qbar'>
<span id='bar_title'>Check:</span>
<a href="#" id='show_courts' class ='short_filter'>One</a>
<a href="#" id='show_clubs' class ='short_filter'>Two</a>
<a href="#" id='show_courts' class ='short_filter'>Three</a>
<a href="#" id='show_courts' class ='short_filter'>Four</a>
</div>
I then added an extra style to float the left_bar to the left
#left_bar {
float: left;
}
I found that this fixed the black box issues.
Not sure what you mean about the wrapping/overflow issues.

if u add vertical-align: top; to #left_bar a the align problem will be gone.
when you float something, its gonna stand in its original height. and as the #left_bar is there filling the whole row, #right_bar falls down. to fix it you should put #right_bar div before #left_bar like this
<div id='quick_bar' >
<div id='bar_title'>
<span>Check:</span>
</div>
<div id='right_bar'>
<a href="#" id='hideSearchBtn'class='list-group-item'>
<span id='DownGly' class ='glyphicon glyphicon-chevron-down'>
</span>
<span id='UpGly' class ='glyphicon glyphicon-chevron-up' style="visibility: hidden;">
</span>
</a>
</div>
<div id='left_bar' class='qbar'>
<a href="#" id='show_courts' class ='short_filter'>One</a>
<a href="#" id='show_clubs' class ='short_filter'>Two</a>
<a href="#" id='show_courts' class ='short_filter'>Three</a>
<a href="#" id='show_courts' class ='short_filter'>Four</a>
</div>
</div>
CSS:
#quick_bar {
width:320px;
background-color: white;
height: 18px;
border-radius: 3px;
margin-top: 2px;
border: 1px solid;
border-color: #dbdbdb;
}
#left_bar a{
margin-left: 4px;
margin-right: 3px;
font-size: 11px;
height: 18px;
font-style: Arial;
font-weight: bold;
vertical-align: top;
}
#bar_title {
float: left;
font-size: 11px;
font-style: Arial;
font-weight: bold;
margin-left: 4px;
}
#right_bar a {
color: black;
}
#right_bar {
height: 18px;
width: 10%;
float: right;
background-color: black;
}

The browser is adding default styles to your anchor tag. Try changing the display type for your links to display:block; or you can float your links left and add padding/margin to separate them. You can also add line-height: 17px; to your span. That should do the trick as well.

Related

Placing elemenents with css?

I want to place image floated left, next to image, floated left one under another would be Authro, Date and Category, than, after this other elements will be floated on right side...
Like this...
https://i.imgur.com/tcKwalP.png
This is what I have so far...
https://jsfiddle.net/fbn9r3y4/
This is html...
<div class="entry-meta">
<span class="entry-image">
<a class="entry-image-a" href="">
<img src="image.jpg" height="48" width="48">
</a>
</span>
<span class="entry-author">
Ester
</span>
<span class="entry-date">September 3, 2019</span>
<span class="entry-category-single">
Music
</span>
<span class="meta-right">
<span class="entry-views"><span class="view-count">998</span> Views</span>
<span class="entry-like">
<span class="sl-wrapper">
<a href="" class="sl-button">
<span class="sl-count">500<em>Likes</em></span>
</a>
<span class="sl-loader"></span>
</span>
</span>
</span>
</div>
This is css...
.entry-meta {
font-family: Arial, sans-serif;
display: block;
align-items: center;
border-top: 1px solid #f3f3f3;
border-bottom: 1px solid #f3f3f3;
padding: 10px 2px;
}
.entry-image {
display: block;
float: left;
}
.entry-author {
display: block;
float: left;
width: 200px;
}
.entry-date {
display: block;
float: left;
width: 200px;
clear: left;
}
.entry-category-single {
display: block;
float: left;
width: 200px;
clear: left;
}
.meta-right {
margin: 0 10px 0 0;
margin-left: auto;
order: 2;
float: right;
}
.entry-like {
min-width: 32px;
line-height: 1;
float: right;
clear: right;
}
.entry-views {
min-width: 32px;
line-height: 1;
float: right;
clear: right;
}
I changed up your markup a little bit and added a wrapping meta-left around the content of the left side. I also simplified your CSS. There were several CSS properties that were invalid or not necessary.
.entry-meta {
font-family: Arial, sans-serif;
border-top: 1px solid #f3f3f3;
border-bottom: 1px solid #f3f3f3;
padding: 10px 2px;
}
.entry-meta::after {
content: '';
clear: both;
display: block;
}
.meta-left {
float: left;
}
.meta-right {
float: right;
margin: 0 10px 0 0;
}
.entry-image {
float: left;
}
.meta-info {
float: left;
margin-left: 10px;
}
.entry-like {
min-width: 32px;
line-height: 1;
}
.entry-views {
min-width: 32px;
line-height: 1;
}
<div class="entry-meta">
<div class="meta-left">
<div class="entry-image">
<a class="entry-image-a" href="">
<img src="https://via.placeholder.com/48" height="48" width="48">
</a>
</div>
<div class="meta-info">
<div class="entry-author">
Ester
</div>
<div class="entry-date">September 3, 2019</div>
<div class="entry-category-single">
Music
</div>
</div>
</div>
<div class="meta-right">
<div class="entry-views"><span class="view-count">998</span> Views</div>
<div class="entry-like">
<span class="sl-wrapper">
<a href="" class="sl-button">
<span class="sl-count">500<em> Likes</em></span>
</a>
<span class="sl-loader"></span>
</span>
</div>
</div>
</div>
Here's a version using display: flex that's even simpler. Same markup.
.entry-meta {
font-family: Arial, sans-serif;
border-top: 1px solid #f3f3f3;
border-bottom: 1px solid #f3f3f3;
padding: 10px 2px;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.meta-left {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
}
.meta-info {
margin-left: 10px;
}
<div class="entry-meta">
<div class="meta-left">
<div class="entry-image">
<a class="entry-image-a" href="">
<img src="https://via.placeholder.com/48" height="48" width="48">
</a>
</div>
<div class="meta-info">
<div class="entry-author">
Ester
</div>
<div class="entry-date">September 3, 2019</div>
<div class="entry-category-single">
Music
</div>
</div>
</div>
<div class="meta-right">
<div class="entry-views"><span class="view-count">998</span> Views</div>
<div class="entry-like">
<span class="sl-wrapper">
<a href="" class="sl-button">
<span class="sl-count">500<em> Likes</em></span>
</a>
<span class="sl-loader"></span>
</span>
</div>
</div>
</div>
Esteros. Please check this link
https://codepen.io/juricon/pen/QWLOZea
HTML:
<div class="entry-meta">
<span class="entry-image">
<a class="entry-image-a" href="">
<img src="image.jpg" height="48" width="48">
</a>
</span>
<ul class="left-float-list">
<ol>
<a href="" title="" rel="author">
Ester
</a>
</ol>
<ol>
September 3, 2019
</ol>
<ol>
<a href="">
Music
</a>
</ol>
</ul>
<ul class="right-float-list">
<li class="items-reverse">
<span class="entry-views">
<!--do not miss nesting rules <tag><tag1></tag1</tag> -->
998
</span>
<span class="view-count">
Views
</span>
</li>
<li>
<span class="entry-like">
<span class="sl-wrapper"> <!--do not miss nesting rules <tag><tag1></tag1</tag> Also, you don't have in CSS classes like .sl-wrapper .sl-button, .sl-count, sl-loader -->
<a href="" class="sl-button">
<span class="sl-count">
500<em>Likes</em>
</span>
<!-- it is a bad idea to use <em> with not cursive text in one <span>. Use CSS to style your text -->
</a>
<span class="sl-loader">
</span>
</span>
</span>
</li>
<li>
Whatever
</li>
</ul>
CSS:
*{ /*clear styles*/
margin:0;
padding:0;
/*clear styles*/
}
.entry-meta {
font-family: Arial, sans-serif;
display: block;
border-top: 1px solid #f3f3f3;
border-bottom: 1px solid #f3f3f3;
padding: 10px 2px;
}
.entry-image{
float: left;
}
.left-float-list{
float: left;
width: 200px;
list-style:none;
background: green;
margin-left:.4em;
}
.right-float-list{
float: right;
list-style:none;
background: red;
margin-right:1em;
}
.entry-views, .entry-like {
min-width: 32px;
line-height: 1;
}
Esteros, here you will find a great web development free course https://www.freecodecamp.org/ and
https://www.w3schools.com/html/default.asp.
It will help you a lot. Good luck!
P.S.: Use Flexbox instead of "float" and you won't regret.

css margin-left not running on safari

I am having trouble with using margin-left with safari
here's my css
<style>
.profile___options {
position: absolute; width: 828px; height: 45px; border-top: 1.1px solid #eee; margin-top: 97px; margin-left: 282px;
}
.profile___options ul {
float: right;
margin-right: 329px;
}
.profile___options ul li {
border-right: 1px solid #e9eaed;
float: left;
font-size: 15px;
font-weight: 600;
height: 43px;
position: relative;
list-style: none;
vertical-align: middle;
white-space: nowrap;
cursor: pointer;
padding: 16px;
color: #365899;
padding: -1px;
}
</style>
and here's my html code
<div class="profile___options">
<div class="fsaafFDSA__">
<div class="223__adAas">
<div class="profile___options_inner">
<ul class="user_ul">
<li>
<a class="questions_link">Questions</a>
</li>
<div class="user_bookmark" style="
position: absolute;
margin-left: -121px;">
</div>
<li style="width: 136px;" class="followerLink">
<!--<span class="badge badge-danger" style="color: #fff;background-color: #dc3545;width: 19px;margin-top: 5px;position: absolute;margin-left: -7px;">3</span>-->
Followers
</li>
<li style="width: 136px;" class="followingLink">
<!--<span class="badge badge-danger" style="color: #fff;background-color: #dc3545;width: 19px;margin-top: 5px;position: absolute;margin-left: -7px;">3</span>-->
Following
</li>
</ul>
</div>
</div>
</div>
</div>
and here's the result on chrome
result on chrome
and here's the result on safari
Result on safari
what I am trying to accomplish is to keep the bottom navbar with the black outline to be aligned at the same place on both browsers
Thanks,
Arnav
Try this:
-webkit-margin-start (left)
-webkit-margin-end (right)
https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariCSSRef/Articles/StandardCSSProperties.html
Hope I helped.

Bootstrap: Need help to center a button

Im trying to center this button but can't seem to get it to work, any help is much appreciated.
<div class="cta-btn">
<a class="btn btn-cta text-center" href="#" role="button">EXPLORE</a>
</div>
And the CSS
.btn-cta{
padding: 25px 80px;
border: 3px solid white;
background-color: transparent;
color: white;
font-family: Tahoma, Verdana, Segoe, sans-serif;
text-transform: uppercase;
font-size: 1.4em;
transition: all 0.3s ease;
}
Put the .text-center class on the enclosing div
<div class="cta-btn text-center">
<a class="btn btn-cta" href="#" role="button">EXPLORE</a>
</div>
Also, if you want the button to fill the width of the div, add the .btn-block class to the button.
use class text-center
<div class="cta-btn text-center">
<a class="btn btn-cta text-center" href="#" role="button">EXPLORE</a>
</div>
Did you try adding text-align: center;
display: block;
margin: 0 auto;

Custom button, that doesn't want to work properly when I am switching to another language

I am trying to create a button just like this one. This button already works fine in the English version, but when I switch to french, it breaks. The French text is much longer, and the button breaks into two separate parts. Any ideas how I can create a "responsive" (text size relative) button?
My code:
<div class="row-fluid">
<div class="text-box text-center"><p>View By</p></div>
<div class="btn-group pull-right small-tab" style="padding-right:20px">
<button class="btn dropdown-toggle" data-toggle="dropdown">
<span class="fa fa-bars"></span>
</button>
<ul class="dropdown-menu pull-right">
<li </li>
<li </li>
<li </li>
</ul>
</div>
</div>
.text-box {
display: inline-block;
height: 27px;
min-width: 70px;
border: 1px solid #c2c2c2;
border-radius: 3px 0 0 3px;
font-size: 14px;
padding: 1px 0 0 0;
margin-right: -1px;
text-align: center;
margin-left: 225px;
p {
margin-top: 5px;
}
}
.small-tab {
.btn:first-child {
border-radius: 0px 3px 3px 0px;
}
}
.btn-group.open .btn.dropdown-toggle {
background-color:#1388e2;
}
.btn {
color:#ffffff;
background-color:#46a9f8;
border: none;
}
.btn:hover {
color:#ffffff;
background-color:#128ded;
}

entire clickable <div> with nested divs

What I'm trying to do is to change the background color on the whole "row" div on mouse over and open the href link clicking on any part of the div. I have tried all the solutions I found on SO (both with jquery and pure css) but I can't get it working
Here is my code:
HTML
<div id="row">
<div class="document-date"><?php the_time('d-m-Y') ?></div>
<div class="document-category"><img src="/images/icon.png" /></div>
<div class="document-title">My link
<p>some description</p>
</div>
And the CSS
#row {
position: relative;
width: 700px;
padding: 5px 0 5px 10px;
display: block;
float: left;
}
#row:hover {
background: #fbf5d8;
}
.document-date{
float: left;
color: #1b6392;
font-size: 12px;
margin-right: 10px;
line-height: 35px;
}
.document-category{
float: left;
margin-right: 10px;
line-height: 35px;
}
.document-title {
width: 350px;
float: left;
color: #020100;
font-size: 12px;
font-weight: normal;
margin-top: 1px;
text-decoration: none;
}
.document-title a{
width: 350px;
float: left;
color: #020100;
font-size: 14px;
font-weight: bold;
margin-top: 1px;
text-decoration: none;
display: block;
width: 100%;
height: 100%;
}
.document-title a:hover{
color: #fff;
}
Any suggestion?
Assuming when you say li, you mean div#row
CSS:
#row:hover {
cursor: pointer
}
JavaScript (using jQuery):
$('#row').click(function() {
// do something
// example:
$(this).find('a:first').click();
});
<div id="row" onclick="alert(1)">
<div class="document-date" >12-08-2014</div>
<div class="document-category" ><img src="/images/icon.png" /></div>
<div class="document-title" ><a href="myurl..." target="_blank" >My link</a><br/><p>some description</p>
</div>​
This would do the trick.
Or if you want the divs separately
<div id="row">
<div class="document-date" onclick="alert(1)">12-08-2014</div>
<div class="document-category" onclick="alert(1)" ><img src="/images/icon.png" /></div>
<div class="document-title" onclick="alert(1)"><a href="myurl..." target="_blank" >My link</a><br/><p>some description</p>
</div>​

Resources