I have a list block where i have a "Get Data" button with an icon. Now I want to move this icon a bit down and make the font bigger however when I attempt to do this the list item is not aligned with the other items (it sets itself a bit lower than the other items)
Can anyone help me with the best way of doing this since I really want the items on the list to be text-aligned.
.item-card {
display: block;
box-shadow: rgba(0, 0, 0, 0.35) 0 5px 15px;
cursor: pointer;
font-family: Titillium Web, sans-serif;
max-height: 70px;
}
.item-card:focus {
border: #b20c1c solid;
}
.justified-list {
padding: 5px;
width: 100%;
margin: 0;
}
button {
background: none;
color: inherit;
border: none;
padding: 0;
font: inherit;
cursor: pointer;
outline: inherit;
}
button:hover:active:focus {
background-color: white;
color: #61070f;
}
.jl-item {
padding: 20px;
display: inline-block;
}
.jl-item:focus{
border: #61070f solid;
}
.btn-hent-pass {
color: #b20c1c;
text-decoration: none;
}
.float {
max-width: 1200px;
margin: 0 auto;
}
.float:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.float-item {
float: left;
}
.last{
float: right;
}
.iconStyle{
font-size: 25px;
position: relative;
top: 3px;
}
#media only screen and (max-width: 320px) {
}
#media only screen and (min-width: 345px) {
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" rel="stylesheet"/>
<div class="item-card float">
<ul class="justified-list">
<li class="jl-item float-item" tabindex="0">16-06-2021</li>
<li class="jl-item float-item" tabindex="0">Text</li>
<li class="jl-item last float-item"><button class="btn-hent-pass" (click)="click.emit()" >Get Data <i class="fas fa-download iconStyle"> </i></button>
</li>
</ul>
</div>
<div class="item-card float">
<ul class="justified-list">
<li class="jl-item float-item" tabindex="0">16-06-2021</li>
<li class="jl-item float-item" tabindex="0">Text</li>
<li class="jl-item last float-item"><button class="btn-hent-pass" (click)="click.emit()" >Get Data <i class="fas fa-download iconStyle"> </i></button>
</li>
</ul>
</div>
.iconStyle{
font-size: 16px;
position: relative;
top: 3px;
}
simply remove the top: 3px; from the code and it will align.
Try to increase the line height or make it match the img. Some fonts just sit lower than others...
Related
So this problem is making me go crazy guys. I created a dropdown menu using Boostrap 4, however when the screen is mobile size I used media query. I want to make my dropdown menu use 100% with when in mobile, and I already tried putting width 100% in some divs or position fixed, but none of that worked.
Here is my screen:
The part that is marked in blue is the one that I want to cover the whole screen.
Here is my HTML code:
<div class="notification-container dropdown">
<button
class="btn notification-button"
type="button"
id="dropdownMenuButton"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>
<i class="fa fa-bell-o"></i>
</button>
<div
class="dropdown-menu dropdown-menu-right notification-container-header"
aria-labelledby="dropdownMenuButton"
>
{{ notifications.length }} notificações
<div class="notification-container-list-body">
<ul class="list-group list-group-flush">
<ng-template
ngFor
let-notification
[ngForOf]="notifications"
let-i="index"
>
<ng-template [ngIf]="notification.imagem">
<li class="notification-container-list-body-item">
<a
class="list-group-item notification-container-list-body-item-image"
routerLink="{{ notification.link }}"
>
<img src="{{ notification.imagem }}" alt="" />
<div>
<div>
{{ notification.titulo }}
</div>
<div>
{{ notification.descricao }}
</div>
</div>
</a>
<button
class="btn delete-notification"
(click)="dropdownPersist($event)"
(click)="deleteNotification(notification.id)"
>
<i class="fa fa-close"></i>
</button>
</li>
</ng-template>
<ng-template [ngIf]="!notification.imagem">
<li class="notification-container-list-body-item">
<a
class="list-group-item notification-container-list-body-item-noimage"
href="{{ notification.link }}"
>
<div>
<div>
{{ notification.titulo }}
</div>
<div>
{{ notification.descricao }}
</div>
</div>
</a>
<button
class="btn delete-notification"
(click)="dropdownPersist($event)"
(click)="deleteNotification(notification.id)"
>
<i class="fa fa-close"></i>
</button>
</li>
</ng-template>
</ng-template>
</ul>
</div>
</div>
</div>
And here is my SCSS code:
p,
a {
margin: 0;
padding: 0;
border: 0;
text-decoration: none;
}
.notification-button {
border-color: transparent;
box-shadow: none;
i {
color: #fff;
}
&:focus {
i {
color: #0ff;
}
}
}
.notification-container-header {
text-align: center;
font-size: 0.9rem;
padding-top: 0px;
padding-bottom: 0px;
border-bottom: 0px;
border-radius: 0;
background-color: #0ff;
color: #000;
font-weight: 500;
}
.notification-container-list-body {
margin-left: 3px;
margin-right: 3px;
ul {
margin-bottom: 3.5px;
max-height: 250px;
overflow: auto;
}
}
.notification-container-list-body-item {
display: grid;
background: #000;
grid-template-columns: 1fr 0.1fr;
padding: 10px 10px 6px 11px;
border-bottom: 1px solid #fff;
}
.notification-container-list-body-item-image {
background: #000;
display: grid;
grid-template-columns: 0.2fr 1fr;
justify-content: center;
img {
height: 30px;
width: 60px;
padding-right: 9px;
}
div {
text-align: left;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 200px;
color: #fff;
&:nth-child(1) {
font-size: 10px;
}
&:nth-child(2) {
font-size: 14px;
}
}
}
.notification-container-list-body-item-noimage {
#extend .notification-container-list-body-item-image;
grid-template-columns: 1.9fr 0.1fr;
div {
width: 261px;
}
}
.delete-notification {
padding: 0;
border-color: transparent;
box-shadow: none;
i {
height: 12px;
width: 12px;
color: #646464;
}
&:focus {
i {
color: #646464;
}
}
}
#media (max-width: 576px) {
.notification-container-header {
margin-top: 0;
border: 0;
}
.notification-container-list-body-item {
grid-template-columns: 1.7fr 0.3fr;
padding: 10px 10px 6px 11px;
}
.notification-container-list-body-item-image {
img {
height: 30px;
width: 70px;
padding-right: 9px;
align-self: center;
}
div {
color: #fff;
&:nth-child(1) {
font-size: 12px;
}
&:nth-child(2) {
font-size: 16px;
}
}
}
.notification-container-list-body-item-noimage {
grid-template-columns: 2.3fr 0.3fr;
}
}
I am also using Angular 9, to make dynamic content.
Can some one help?
.notification-container-list-body {
width: 100%; <=====================================================
margin-left: 3px;
margin-right: 3px;
ul {
margin-bottom: 3.5px;
max-height: 250px;
overflow: auto;
}
}
I am creating a footer used in a layout on every page. The footer has two div tags that look like buttons. The problem i am running into is the button are smaller on some screens and larger on others. It looks like if the content of the page does not take the full height of the screen, the footer buttons are the correct size. If the content of the page is over the full height of the screen the buttons are smaller. I believe they should stay the same height.
Here is some screenshots:
.footer {
bottom: 0;
background-color: #EEEEEE;
width: 100%;
height: 100%;
}
.footer-container {
margin: 0 auto;
max-width: 1200px;
padding-bottom: 15px;
border-bottom: 1px solid #cccccc;
}
.footer-list {
display: flex;
list-style-type: none;
justify-content: flex-end;
margin: 0;
padding-top: 15px;
color: #444444;
}
.footer-left {
margin-right: auto;
padding-top: 15px;
padding-left: 10px;
}
.footer-item {
font-size: .9rem;
margin-right: 1rem;
padding-top: 9px;
}
.footer-button {
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.9rem;
margin: 2px 2px;
cursor: pointer;
border-radius: 4px;
}
.footer-help-center {
background-color: #0B5C8E;
border: 2px solid #0B5C8E;
color: white;
padding: 5px 30px 5px 30px;
}
<div class="footer">
<div class="footer-container">
<div class="footer-list">
<li class="footer-left">
<img src="~/content/images/logo-icon.png">
</li>
<li class="footer-item">
<div class="footer-button footer-help-center">Help Center</div>
</li>
<li class="footer-item">
<a href="#Url.RouteUrl(" ContactUs ")">
<div class="footer-button footer-contact-us">Contact Us</div>
</a>
</li>
</div>
</div>
</div>
Relative length units specify a length relative to another length property. Relative length units scales better between different rendering mediums.
rem: Relative to font-size of the root element
CSS Units
From this I can say when you are using rem which could be depended on root element font size or browser font size. That will make your website renders bit different between browsers.
For one you are missing the element <ul> wrapping your <li>. After that I would suggest to clean up elements that don't need to be there, take a look at my example. Like you don't need to have a div inside the <a> element.
.footer {
bottom: 0;
background-color: #EEEEEE;
width: 100%;
height: 100%;
}
.footer-container {
margin: 0 auto;
max-width: 1200px;
padding-bottom: 15px;
border-bottom: 1px solid #cccccc;
}
.footer-list {
display: flex;
list-style-type: none;
justify-content: flex-end;
margin: 0;
padding-top: 15px;
color: #444444;
}
.footer-left {
margin-right: auto;
padding-top: 15px;
padding-left: 10px;
}
.footer-item {
font-size: .9rem;
margin-right: 1rem;
padding-top: 9px;
}
.footer-button {
text-align: center;
text-decoration: none;
font-size: 0.9rem;
margin: 2px 2px;
cursor: pointer;
border-radius: 4px;
}
.footer-help-center {
background-color: #0B5C8E;
border: 2px solid #0B5C8E;
color: white;
padding: 5px 30px 5px 30px;
}
.footer-contact-us {
background-color: deepskyblue;
border: 2px solid #0B5C8E;
color: white;
padding: 5px 30px 5px 30px;
}
<div class="footer">
<div class="footer-container">
<ul class="footer-list">
<li class="footer-left">
<img src="~/content/images/logo-icon.png">
</li>
<li class="footer-item">
<a class="footer-button footer-help-center">Help Center</a>
</li>
<li class="footer-item">
<a href="#Url.RouteUrl(" ContactUs ")" class="footer-button footer-contact-us">
Contact Us
</a>
</li>
</ul>
</div>
</div>
I tried playing around a bit but can't seem to replicate exactly what you are seeing other than the text wrapping when the window gets narrow. The css for footer-contact-us is missing but I assume it's about the same as footer-help-center.
If you want the buttons to always be the same height, why not just tell them to be?
.footer-button {
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.9rem;
margin: 2px 2px;
cursor: pointer;
border-radius: 4px;
height:20px;
line-height:20px;
}
You can use this code
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Hello, world!</title>
<style type="text/css">
body {
margin: 0;
}
.footer {
bottom: 0;
background-color: #EEEEEE;
width: 100%;
height: 100%;
}
.footer-container {
margin: 0 auto;
max-width: 1200px;
padding-bottom: 15px;
border-bottom: 1px solid #cccccc;
}
.footer-list {
display: flex;
list-style-type: none;
justify-content: flex-end;
margin: 0;
padding-top: 15px;
color: #444444;
}
.footer-left {
margin-right: auto;
padding-top: 5px;
padding-left: 10px;
}
.footer-item {
margin-right: 1rem;
}
.footer-button {
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 0.9rem;
margin: 2px 2px;
cursor: pointer;
border-radius: 4px;
}
.footer-help-center.success {
background-color: #0B5C8E;
border: 2px solid #0B5C8E;
color: white !important;
padding: 5px 30px 5px 30px;
font-size: 14px;
cursor: pointer;
}
.footer-contact-us.info {
background-color: #33691e;
border: 2px solid #33691e;
color: white !important;
padding: 5px 30px 5px 30px;
font-size: 14px;
cursor: pointer;
outline: none;
box-shadow: none;
text-decoration: none;
}
</style>
</head>
<body>
<div class="footer">
<div class="footer-container">
<div class="footer-list">
<li class="footer-left">
<img src="~/content/images/logo-icon.png">
</li>
<li class="footer-item">
<a class="btn success footer-button footer-help-center">Help Center</a>
</li>
<li class="footer-item">
<a class="btn info footer-button footer-contact-us" href="#Url.RouteUrl(" ContactUs ")">Contact Us</a>
</li>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
I have a div inside which there is a text which has a subtitle that must always be positioned on the bottom right in this manner
I achieved this by making the parent div relative and the contents inside it as absolute.But the upper text can grow to whatever length and i want the parent div to expand with it and not overlay other elements which it is doing as shown in the image
Here is what i tried.
header {
height: 60px;
padding: 0 12px;
background: #fff;
position: fixed;
width: calc(100% - 24px);
z-index: 999999; // no z-index values above this for any body elements
box-shadow: 7px -9px 6px 6px $black;
left: 0;
li {
float: right;
display: block;
margin-left: 20px;
padding: 20px 0;
width: 18px;
text-align: right;
i {
color: $icon-grey;
font-size: $header-icon-size;
cursor: pointer;
&.fa-times {
color: $icon-red;
}
&.notify{
color: gold;
}
&.fa-caret-down{
color: gold;
}
}
img{
width: 40px;
height: 40px;
border-radius: 50%;
margin-top: -0.7em;
object-fit: cover;
object-position: center right;
}
}
.user-info {
text-align: right;
display: inline-block;
margin-top: -0.5em;
h5{
color: $section;
}
span{
color: $icon-grey;
font-size: 14px;
}
}
.user-details{
margin-right: 15px;
}
}
<header>
<li>
<i class="fas fa-caret-down"></i>
</li>
<li>
<img src="{{user.image}}">
</li>
<li>
<div class="user-info">
<h4>Smith</h4>
<p>CAD</p>
</div>
</li>
<li class="notification-menu">
<i class="fas fa-bell"></i>
</li>
</header>
All elements inside header are aligned on the right side.
I could not find any solution that just uses css.
Just use text-align:right...it seems to be adequate. No need for extra fancy layout options unless there is more to this than it appears.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
::before,
::after {
box-sizing: inherit;
}
.user-info {
text-align: right;
display: inline-block;
border: 1px solid grey;
}
<div class="user-info">
<h4>Smith</h4>
<p>CAD</p>
</div>
<div class="user-info">
<h4>Longer name - Smith</h4>
<p>CAD</p>
</div>
<div class="user-info">
<h4>Smith</h4>
<p>Longer Initials CAD</p>
</div>
I am having an issue with the second level menu only in Safari. Top level and submenu work fine on mouse hover on chrome, firefox etc but when opened in Safari, only first menu is opening on hover. I have already tried other solutions available here and on other forums but it's still same.
.nav {
margin: 2% 10% 0 35%;
/*margin-bottom: 4px;
margin-top: 2%;
margin-left: 35%;
margin-right: 10%;*/
width: 60%;
height: auto;
z-index: 1;
position: absolute;
}
.nav-container {
display: inline-block;
padding: 0;
font-weight: 300;
font-family:"Open Sans";
font-size: 15px;
}
.nav-container a:hover {
color: #FFFFFF;
}
.nav-pos {
display: inline-block;
padding-bottom: 15px;
}
.nav-pos-sp {
/*padding-left: 30px;*/
padding-left: 0px !important;
margin-left: 30px;
}
.navbar-nav {
margin-top: 1%;
display: none;
height: auto;
color: #C7C7C7;
width: 200px;
overflow: hidden;
position: fixed;
}
.navbar-nav-menu a {
font-size: 14px;
display: block;
text-align: left;
padding: 15px 0px 15px 12px;
border-bottom: thin solid #fff;
background-color: #343434;
}
/* child menu dropdown */
.navbar-nav-child {
display: none;
height: auto;
color: #C7C7C7;
width: 200px;
overflow: hidden;
position: fixed;
margin-left: -200px;
margin-top: -50px;
}
.navbar-nav-menu-item-101a:hover .navbar-nav-child {
margin-left: 200px !important;
display: block !important;
}
.navbar-nav-menu-child-text a {
font-size: 14px;
display: block;
text-align: left;
padding: 15px 0px 15px 12px;
border-bottom: thin solid #fff;
background-color: #2B2B2B;
}
.services:hover .navbar-nav-menu {
display: block;
}
<html>
<head>
<link rel="stylesheet" href="../style/all.css.cf.css" type="text/css"/>
<link rel="stylesheet" type="text/css"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"/>
</head>
<body>
<div class="nav">
<div class="nav-container">
<div class="nav-pos nav-pos-sp services">
First Menu <span class="fa fa-angle-down"></span>
<div class="navbar-nav navbar-nav-menu navbar-nav-services">
<ul>
<li class="navbar-nav-menu-item-101a"><a href="#0">Second Level Menu <span class="fa fa-angle-right"
style="float: right;margin-right: 10px;"></span></a>
<div class="navbar-nav-child navbar-nav-menu-child-text">
1
2
3
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
I have included the HTML and CSS code for the menu. I have also checked it on chrome using windows OS, and it works but the only issue is with safari browser.
There are a couple of suggestions I have that may help.
Firstly, I would not recommend using position: fixed; to position your submenus because fixed is a position relative to the browser window. You likely want the submenus to be positioned according to the parent, not the window.
Secondly, you have overflow: hidden; on .navbar-nav, which means anything that falls outside the borders of it should be invisible - which would include your submenus.
Here is a JSFiddle with a working example of your snippet with my suggestions, tested and working in Safari:
.nav {
margin: 2% 10% 0 35%;
width: 60%;
height: auto;
z-index: 1;
position: absolute;
}
.nav-container {
display: inline-block;
padding: 0;
font-weight: 300;
font-family: "Open Sans";
font-size: 15px;
}
.nav-container a:hover {
color: #FFFFFF;
}
.nav-pos {
display: inline-block;
padding-bottom: 15px;
}
.nav-pos-sp {}
.navbar-nav {
margin-top: 1%;
display: none;
height: auto;
color: #C7C7C7;
width: 200px;
position: relative;
}
.navbar-nav-menu a {
font-size: 14px;
display: block;
text-align: left;
padding: 15px 0px 15px 12px;
border-bottom: thin solid #fff;
background-color: #343434;
}
/* child menu dropdown */
.navbar-nav-child {
display: none;
height: auto;
color: #C7C7C7;
width: 200px;
position: absolute;
top: 0;
left: 100%;
}
.navbar-nav-menu-item-101a:hover .navbar-nav-child {
display: block !important;
}
.navbar-nav-menu-child-text a {
font-size: 14px;
display: block;
text-align: left;
padding: 15px 0px 15px 12px;
border-bottom: thin solid #fff;
background-color: #2B2B2B;
}
.services:hover .navbar-nav-menu {
display: block;
}
<html>
<head>
<link rel="stylesheet" href="../style/all.css.cf.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />
</head>
<body>
<div class="nav">
<div class="nav-container">
<div class="nav-pos nav-pos-sp services">
First Menu <span class="fa fa-angle-down"></span>
<div class="navbar-nav navbar-nav-menu navbar-nav-services">
<ul>
<li class="navbar-nav-menu-item-101a"><a href="#0">Second Level Menu <span class="fa fa-angle-right"
style="float: right;margin-right: 10px;"></span></a>
<div class="navbar-nav-child navbar-nav-menu-child-text">
1
2
3
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
https://jsfiddle.net/m59vk802/4/
I've a div (.user-band), inside it there is one div (.user-block) floated to left and one UL (.user-stats) floated to right.
Now the issue is when I'm giving width/min-width in percentage to child 'li' items of 'ul' (.user-stats). The 'li' items are not appearing in a row within 'ul', but if i'm giving the same width in pixel (i.e. 250px) they are appearing in a row.
Can anyone please let me know whats going wrong here.
Here is the HTML:
<div class="clearfix user-band">
<div class="clearfix user-block">
<div class="user-pic">
<div class="pic-box">
<img src="images/user-pic.jpg" alt="">
</div> <!--pic-box-->
</div> <!--user-pic-->
<div class="user-info">
<p class="user-id">Martin</p>
<p class="user-location"><span class="fa fa-map-marker ic-location"></span> Los Angeles</p>
</div> <!--user-info-->
</div> <!--user-block-->
<ul class="user-stats">
<li class="stats-title">
Completed Deals
<span class="stats-value">15</span>
</li>
<li class="stats-title">
Pending Deals
<span class="stats-value">7</span>
</li>
<li class="stats-title no-click">
Total Commission
<span class="stats-value">$500</span>
</li>
</ul>
</div> <!--user-band-->
Here is the CSS:
.user-band { border: 1px solid #e26513; background: #F0701B; padding: 10px; }
.user-block { float: left; }
.user-pic, .user-info { float: left; }
.user-info { margin-left: 10px; }
.user-pic { padding: 2px; border-radius: 2px; background: #ffffff; }
.pic-box { overflow: hidden; text-align: center; width: 80px; height: 80px; }
.pic-box > img { max-width: 100%; min-height: 100%; }
.user-id { font-weight: 700; font-size: 18px; color: #ffffff; }
.user-location { color: #ffffff; }
.user-stats { float: right; margin: -10px -10px -10px 0; list-style-type: none; padding-left: 0; }
.user-stats { float: right; margin: -10px -10px -10px 0; list-style-type: none; padding-left: 0; }
.user-stats > li { display: inline-block; min-width: 250px; padding: 24px 10px; text-align: center; font-size: 14px; color: #ffffff; border-left: 1px solid #e26513; margin-left: -4px; cursor: pointer; }
.user-stats > li:hover { box-shadow: 0 0 200px #e26513 inset; }
.stats-value { font-weight: 700; display: block; font-size: 25px; }
.user-stats > li.no-click { cursor: auto; }
.user-stats > li.no-click:hover { box-shadow: none; }
.ic-location { font-size: 20px; }
You need to set a width on the UL - because it is floated.
http://codepen.io/elliz/pen/IeDCd/
15 Apr - Pen updated
See updated pen, what that what you mean?
Note - made code a little more semantic but not perfect.