I'm trying to create a navbar which contains a title, some buttons and a username. I'm trying to align the buttons to the center and the username to the right, while the title stays to the left. Whatever I try, I can't get it to work. It either centers the buttons and the username, or it aligns it all to the left.
I have the feeling some conflicting styling is causing the problem, however I'm not sure and was wondering if someone could help me out.
.sidenav-container {
height: 100%;
}
.sidenav {
width: 200px;
}
.sidenav .mat-toolbar {
background: inherit;
}
.mat-toolbar.mat-primary {
position: sticky;
top: 0;
z-index: 1;
}
a {
text-decoration: none;
color: white;
}
a:hover,
a:active {
color: lightgray;
}
.icon {
display: inline-block;
height: 30px;
margin: 0 auto;
padding-right: 15px;
text-align: center;
vertical-align: middle;
width: 15%;
}
.label {
display: inline-block;
line-height: 30px;
margin: 0;
width: 85%;
}
#footer {
position:fixed;
left:0px;
bottom:0px;
height:40px;
width:100%;
background: white;
}
#menu
{
width: 100%;
margin: 0;
padding: 20px 0 0 0;
list-style: none;
display: inline-block;
}
#menu > li:last-child{
float: right;
}
<mat-sidenav-container>
<mat-sidenav #sidenav role="navigation">
<mat-nav-list>
<a mat-list-item [routerLink]="['post/list']">
<mat-icon class="icon">forum</mat-icon>
<span class="label">Posts</span>
</a>
<a mat-list-item [routerLink]="['news']">
<mat-icon class="icon">chrome_reader_mode</mat-icon>
<span class="label">News</span>
</a>
<a mat-list-item [routerLink]="['about']">
<mat-icon class="icon">dashboard</mat-icon>
<span class="label">About</span>
</a>
<a mat-list-item>
<mat-icon class="icon">output</mat-icon>
<button (click)="logout()">Logout</button>
</a>
</mat-nav-list>
</mat-sidenav>
<mat-sidenav-content>
<mat-toolbar color="primary">
<div fxHide.gt-xs>
<button mat-icon-button (click)="sidenav.toggle()">
<mat-icon>menu</mat-icon>
</button>
</div>
<div>
<a [routerLink]="['']">
BRICKER
</a>
</div>
<div fxFlex fxHide.xs>
<ul fxLayout fxLayoutGap="20px" id="menu">
<a mat-list-item [routerLink]="['post/list']">
<mat-icon class="icon">forum</mat-icon>
<span class="label">Posts</span>
</a>
<li>
<a mat-list-item [routerLink]="['news']">
<mat-icon class="icon">chrome_reader_mode</mat-icon>
<span class="label">News</span>
</a>
</li>
<li>
<a [routerLink]="['about']">
<mat-icon class="icon">dashboard</mat-icon>
<span class="label">About</span>
</a>
</li>
<li>
<span *ngIf="(loggedInUser$ | async) as user" class="label"> <button mat-button [matMenuTriggerFor]="menu"
style="font-size:24px;">{{user}}</button>
<mat-menu #menu="matMenu">
<button mat-menu-item [routerLink]="['post/owned']">My Posts</button>
<button mat-menu-item (click)="logout()">Logout</button>
</mat-menu>
</span>
</li>
</ul>
</div>
</mat-toolbar>
<ng-content></ng-content>
</mat-sidenav-content>
</mat-sidenav-container>
Are u expecting like this:
li:last-child {
color: lime;
background-color: black;
text-align:left; /*change this if you want to align right */
padding: 5px;
}
li{
text-align:center;
list-style:none;
}
<ol>
<li>one</li>
<li>two</li>
<li>Three</li>
</ol>
<ol>
<li>four</li>
<li>five</li>
<li>six</li>
</ol>
Related
I am using React and this should be a very simple task yet I am stuck. I cannot get the home container to span the width of my page
Here is my Css code, I originally had two Css files one for the Nav and one for the Home section but started playing around trying to figure out where I went wrong. I have basically now stripped my css and code it all the way down still cant figure out why it wont span completely from side to side
* {
box-sizing: border-box;
}
body {
margin: 0;
}
.site-title {
font-size: 2rem;
}
.nav {
background-color: #333;
color: antiquewhite;
display: flex;
justify-content: space-between;
align-items: stretch;
gap: 2rem;
padding: 0 1rem;
}
.nav ul{
display: flex;
gap: 1rem;
padding: 0%;
margin: 0%;
list-style: none;
}
.nav a{
display: flex;
color: inherit;
text-decoration: none;
height: 100%;
align-items: center;
padding: .55rem;
}
.nav li.active {
background-color: #555;
}
.nav li:hover{
background-color: #777;
}
.home-container {
background-color: #111;
}
.home-parent {
display: flex;
align-items: center;
color: aliceblue;
}
My HTML
import Typical from "react-typical";
export default function Home() {
return (
<div className="home-container">
<div className="home-parent">
<div className="profile-details">
<div className="colz">
<div className="colz-icon">
<a href="#">
<i className="fa fa-facebook-square"></i>
</a>
<a href="#">
<i className="fa fa-instagram"></i>
</a>
<a href="#">
<i className="fa fa-youtube-square"></i>
</a>
<a href="#">
<i className="fa fa-twitter"></i>
</a>
</div>
</div>
<div className="Home-details-name">
<span className="primary-text">
{""}
Hello, I'm <span className="highlighted-text">Heather</span>
</span>
</div>
<div className="home-details-role">
<span className="primary-text">
{""}
<h1>
<Typical
loop={Infinity}
steps={[
"Fullstack Dev",
1000,
"Web Design",
1000,
"Data bases",
1000,
"Tech Support",
1000,
]}
/>
</h1>
<span className="home-role-tagline">
Knack for building applications with front and backend
operations
</span>
</span>
</div>
<div className="profile-options">
<button className="btn primary-btn">
{""}
Hire Me{""}
</button>
<a
href="Heather-Christensen.pdf"
download="Heather-Christensen.pdf"
>
<button className="btn highlighted-btn">Get Resume</button>
</a>
</div>
</div>
<div className="profile-picture">
<div className="profile-picture-background"></div>
</div>
</div>
</div>
);
}
When I applied padding to 'a' elements, there will be gaps top-borders' left and right.I want the top border covers entire line until navbar's right border. How can I solve this problem.
* {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: 1fr 6fr;
}
.navbar {
border-right: gray 3px solid;
padding: 5%;
position: sticky;
top: 0;
height: 100vh;
box-sizing: border-box;
min-width: 300px;
}
#navbar-header {
text-align: center;
margin-bottom: 20px;
}
#navbar-content a {
text-decoration: none;
color: black;
}
#navbar-content a li {
list-style: none;
padding: 5%;
padding-left: 10%;
border-top: gray 1px solid;
}
<div class="wrapper">
<div class="navbar">
<h2 id="navbar-header">JS Documentation</h2>
<ul id="navbar-content">
<a href="#intro">
<li>Introduction</li>
</a>
<a href="#know">
<li>What you should already know</li>
</a>
<a href="#js-java">
<li>JavaScript and Java</li>
</a>
<a href="#hello">
<li>Hello World</li>
</a>
<a href="#var">
<li>Variables</li>
</a>
<a href="#dec-var">
<li>Declaring Variables</li>
</a>
<a href="#var-sco">
<li>Variable Scope</li>
</a>
<a href="#glo-var">
<li>Global Variables</li>
</a>
<a href="#cons">
<li>Constants</li>
</a>
<a href="#data">
<li>Data Types</li>
</a>
<a href="#if-else">
<li>if...else statement</li>
</a>
<a href="#while">
<li>while statement</li>
</a>
<a href="#func">
<li>Function declarations</li>
</a>
<a href="#ref">
<li>Reference</li>
</a>
</ul>
</div>
<div class="contents">
</div>
</div>
When I applied padding to 'a' elements, there will be gaps top-borders' left and right.I want the top border covers entire line until navbar's right border. How can I solve this problem.
Remove the padding-left/right from the navbar and increase the one of the li:
* {
margin: 0;
padding: 0;
font-family: 'Lato', sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: 1fr 6fr;
}
.navbar {
border-right: gray 3px solid;
padding: 5% 0; /*updated*/
position: sticky;
top: 0;
height: 100vh;
box-sizing: border-box;
min-width: 300px;
}
#navbar-header {
text-align: center;
margin-bottom: 20px;
}
#navbar-content a {
text-decoration: none;
color: black;
}
#navbar-content a li {
list-style: none;
padding: 5% 10%; /*updated*/
border-top: gray 1px solid;
}
<div class="wrapper">
<div class="navbar">
<h2 id="navbar-header">JS Documentation</h2>
<ul id="navbar-content">
<a href="#intro">
<li>Introduction</li>
</a>
<a href="#know">
<li>What you should already know</li>
</a>
<a href="#js-java">
<li>JavaScript and Java</li>
</a>
<a href="#hello">
<li>Hello World</li>
</a>
<a href="#var">
<li>Variables</li>
</a>
<a href="#dec-var">
<li>Declaring Variables</li>
</a>
<a href="#var-sco">
<li>Variable Scope</li>
</a>
<a href="#glo-var">
<li>Global Variables</li>
</a>
<a href="#cons">
<li>Constants</li>
</a>
<a href="#data">
<li>Data Types</li>
</a>
<a href="#if-else">
<li>if...else statement</li>
</a>
<a href="#while">
<li>while statement</li>
</a>
<a href="#func">
<li>Function declarations</li>
</a>
<a href="#ref">
<li>Reference</li>
</a>
</ul>
</div>
<div class="contents">
</div>
</div>
I am using Angular 4, Bootstrap 4 alpha 6 (css). I am trying to make each <li> the equal width (not 100% of the navbar). I was trying to use flex box but I cant get it to make them all equal.
I've tried several ways but each time the items will all be a fixed width but not the same width.
Heres an example of what I'm trying to do
[ ---item 1--- | ---item 2--- | ---item 3--- ]
HTML
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<ng-container *ngIf="isLoggedIn">
<span class="navbar-text"> </span>
<ul class="nav navbar-nav ">
<li class="nav-item active">
<a class="nav-link" href="#">Dashboard <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="profileDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
My Account
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item">My Account</a>
<a class="dropdown-item">My Account</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="accountDropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Profile
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" [routerLink]="['/profile', 'view']">My Account</a>
<a class="dropdown-item" [routerLink]="['/profile']">Edit my Profile</a>
</div>
</li>
</ul>
</ul>
</div>
</nav>
CSS
nav ul{
list-style: none;
margin: 0 2px;
padding: 0;
display: flex;
justify-content: space-around;
}
nav li{
width: 100%
}
.nav.navbar-nav > li{
border-right: 2px solid white;
}
EDIT: This works but I would prefer to use flex so that its done automatically
.nav.navbar-nav > li{
border-right: 2px solid white;
width: 200px;
max-width: 200px;
text-align: center;
}
Other ways I've tried
1)
.navbar ul.nav {
!*margin: 0;*!
display: table;
width: 100%;
!*direction: rtl;*!
table-layout: fixed;
margin:0;
padding:0;
}
.navbar ul.nav li {
!*float: right;*!
display: table-cell;
width: 20%;
!*float: none;*!
text-align: center;
!*direction: rtl;*!
}
.navbar .nav > li:hover {
background-color: #808080
}
.navbar .nav li:first-child a {
!*border-left: 0;*!
!*border-radius: 3px 0 0 3px;*!
}
.nav.navbar-nav > li{
!*width: 10%;*!
border-right: 2px solid white;
}
2)
nav {
text-align: center;
margin: 20px 0 0 ;
padding: 10px 0;
}
nav ul{
list-style: none;
margin: 0 2px;
padding: 0;
}
nav li {
display: inline-block;
padding: 5px 5px;
}
nav a {
font-weight: normal;
padding: 10px 5px;
}
Use calc() Basically by dividing 100% width by 3 each li will be 1/3 in width. Next you can set each "a" to 100% (width will be 100% of parent) and display:inline-block (so that width takes effect.
nav li{
width: calc(100% / 3);
}
I really don't see how you can get them to be the same size without giving your <nav> some kind of width. However, if you do give it a width, you can get all your child elements to be the same width using a combination of display: table; and display: table-cell. It's all the niceties of <table> without the syntactic commitment.
nav {
width: 50%;
position: relative;
}
nav ul {
display: table;
padding: 0;
margin: 0;
width: 100%;
}
nav ul li {
text-align: center;
display: table-cell;
border: 1px solid black;
}
<nav>
<ul>
<li>Fizz</li>
<li>Buzz</li>
<li>Foo</li>
</ul>
</nav>
I want to style my unordered list like this one below
Link to what i want to achive
My structure looks like:
<div class="tabs">
<ul class="tabs__labels">
<li class="0">
<a class="active" href="#">
<img/>
<div>something</div>
</a>
</li>
<li class="1">
<a class="" href="#">
<img/>
<div>something1</div>
</a>
</li>
...
</ul>
</div>
Is it a good idea to name the list classes like 0,1 etc. and style them separately to somehow achive this effect? How to use flexbox to get similar effect? Should i group them into rows?
Would this be a start?
.tabs__labels {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
list-style: none;
margin: 0;
padding: 0;
}
.tabs__labels li {
flex-basis: 45%;
margin: 20px 0;
padding: 0;
}
.tabs__labels li:nth-child(odd) {
display: flex;
justify-content: flex-end;
}
.tabs__labels li:nth-child(even) {
display: flex;
}
.tabs__labels li:nth-child(3),
.tabs__labels li:nth-child(4) {
flex-basis: 35%;
}
.tabs__labels li a {
display: flex;
justify-content: center;
align-items: center;
height: 40px;
width: 40px;
border-radius: 50%;
border: 1px solid red;
text-decoration: none;
}
.tabs__labels li:nth-child(1)::before {
content: 'some text';
text-decoration: underline;
margin-right: 10px;
}
.tabs__labels li:nth-child(2)::after {
content: 'some text';
text-decoration: underline;
margin-left: 10px;
}
<div class="tabs">
<ul class="tabs__labels">
<li>
<a class="active" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
<li>
<a class="" href="#">S
</a>
</li>
</ul>
</div>
Given below is my scss
#import "susy";
$susy: (
columns: 12,
gutters: 0,
math: fluid,
output: float,
gutter-position: inside
);
ul {
list-style: none;
width: 240px;
}
li {
display: table-cell;
position: relative;
vertical-align: middle;
width: 60px;
height: 60px;
border-radius: 50%;
color: #019ed5;
border: 1px solid #019ed5;
background-color: white;
cursor: pointer;
text-align: center;
#include span(3);
&:nth-child(4n){
#include span(3 at 10);
}
}
li:hover {
background: #019ed5;
color: #fff;
}
span.detail{
position: relative;
top: 12px;
left: 8px;
}
span.more {
position: relative;
float: right;
width: 20px;
height: 20px;
border-radius: 50%;
background: red;
font-size: 10px;
line-height: 20px;
color: white;
}
And here is my HTML
<ul>
<li>
<span class="more">25</span>
<span class = "detail">Jan<br/>15</span>
</li>
<li>
<span class="more-statement">15</span>
<span class="detail">Feb<br/>15</span>
</li>
<li>
<span class="more">13</span>
<span class="detail">Mar<br/>15</span>
</li>
<li>
<span class="more-statement">8</span>
<span class="detail">Apr<br/>15</span>
</li>
<li>
<span class="more">30</span>
<span class="detail">May<br/>15 </span>
</li>
<li>
<span class="more">6</span>
<span class="detail">Jun<br/>15</span>
</li>
<li>
<span class="more">9</span>
<span class="detail">Jul<br/>15</span>
</li>
<li>
<span class="more">16</span>
<span class="detail">Aug<br/>1</span>
</li>
<li>
<span class="more">0</span>
<span class="detail">Sep<br/>15</span>
</li>
<li>
<span class="more">15</span>
<span class="detail">Oct<br/>15</span>
</li>
<li>
<span class="more">30</span>
<span class="detail">Nov<br/>15</span>
</li>
<li>
<span class="more">21</span>
<span class="detail">Dec<br/>15</span>
</li>
</ul>
http://codepen.io/suhasdeshpande/pen/bVwZmz?editors=110
Above is my codepen and I am really new to Sussy. Having an hard time figuring about how to add spaces between lis in above code.