I'm trying to align span to right of div, the span is within a button.
I have managed to do the above, but I'm having problem vertically aligning the header at the same time keeping it to the left.
.spec-li>li>span {
padding: 5px 0 0 0;
}
.spec-label {
display: block;
float: left;
width: 50%;
font-weight: 700;
font-size: 12px;
}
.spec-value {
display: block;
float: right;
width: 50%;
text-align: right;
font-size: 12px;
}
.card-header-spec {
display: flex;
justify-content: space-between
}
.card-spec-button-font-size {
font-size: 30px
}
.spec-card {
border-width: 0;
border-top-width: 1px;
background-color: none;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<section>
<div class="accordion" id="accordionWeight">
<div class="card spec-card">
<div class="card-header card-header-spec" id="headingOne">
<h5 class="mb-0">Weight</h5>
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
<span class="card-spec-button-font-size">+</span>
</button>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionWeight">
<div class="card-body">
<ul class="list-unstyled spec-li">
<li>
<span class="spec-label">Base Weight</span>
<span class="spec-value">2351 lbs (1064kg)</span>
</li>
<li>
<span class="spec-label">Useful Load</span>
<span class="spec-value">1249 lbs (569kg)</span>
</li>
<li>
<span class="spec-label">Cabin payload with 3 hr trip fuel and 45 min reserve</span>
<span class="spec-value">895 lbs (409 kg)</span>
</li>
</ul>
</div>
</div>
</div>
</div>
</section>
I have attached a screen shot of how it currently looks:
can anyone help with this problem as it would be much appreciated
If you want to align the h5 vertically in the center. Do this.
.card-header-spec {
display: flex;
justify-content: space-between;
}
As you see in the code aboe, card-header-spac,parent of h5, is flex. In bootstrap-4, you use align-items-center to align content of a flex element vertically in its center.
.spec-li>li>span {
padding: 5px 0 0 0;
}
.spec-label {
display: block;
float: left;
width: 50%;
font-weight: 700;
font-size: 12px;
}
.spec-value {
display: block;
float: right;
width: 50%;
text-align: right;
font-size: 12px;
}
.card-header-spec {
display: flex;
justify-content: space-between
}
.card-spec-button-font-size {
font-size: 30px
}
.spec-card {
border-width: 0;
border-top-width: 1px;
background-color: none;
}
If you want to use custom CSS, use align-items: center for the card-header-spec class.
.card-header-spec {
display: flex;
justify-content: space-between;
align-items: center;
}
In CSS, to vertically align, add align-items: center inside card-header-spec.
Below is the modified CSS
.spec-li>li>span {
padding: 5px 0 0 0;
}
.spec-label {
display: block;
float: left;
width: 50%;
font-weight: 700;
font-size: 12px;
}
.spec-value {
display: block;
float: right;
width: 50%;
text-align: right;
font-size: 12px;
}
.card-header-spec {
display: flex;
justify-content: space-between;
align-items: center;
}
.card-spec-button-font-size {
font-size: 30px
}
.spec-card {
border-width: 0;
border-top-width: 1px;
background-color: none;
}
try using the vertical-align property, visit: https://www.w3schools.com/cssref/pr_pos_vertical-align.asp
Related
I'm trying everything, I'm new at this and just cannot get it to work.
I just wanted my logo ("animated") to always align left, and the links to align right. Just like any normal nav bar.
The animated logo works just fine. I just can't separate the logo from the links and align them?
I've tried float: right and margin-right: auto under the animated logo.
.container {
max-width: 1280px;
margin: 0 right;
display: flex;
align-items: center;
justify-content: space-between;
}
nav {
display: flex;
z-index: 50;
background-color: #FFFFFF;
padding: 16px 32px;
}
a {
text-decoration: none;
}
.logo {
display: inline-flex;
}
.animated-logo {
display: flex;
color: #000000;
transition-property: transform;
transition-duration: .15s;
font-size: 35px;
font-weight: 600;
}
menu a {
color: black;
margin: 0 16px;
font-weight: 300;
text-decoration: none;
transition: 0.2s;
padding: 8px 5px;
border-radius: 99px;
font-size: 20px;
}
.menu a:hover {
color: #808080;
}
<nav>
<div class="container">
<a href="index.html" class="logo">
<h3 class="animated-logo">
<span class="letter first">t</span>
<span class="letter">a</span>
<span class="letter-hide">a</span>
<span class="letter">r</span>
<span class="letter">s</span>
<span class="letter-hide">t</span>
<span class="letter">r</span>
</h3>
</a>
<div class="menu">
About
Experience
Contact Me
</div>
</nav>
Add width: 100vw; to the .container.
You only set max-width, which is not enough because the width will be "auto" if there's not enough content, but never more than 1280px.
You want the width to be 100vw if there's not enough content, but never more than 1280px.
See the snippet below.
.container {
width: 100vw; /* Added */
max-width: 1280px;
margin: 0 right;
display: flex;
align-items: center;
justify-content: space-between;
}
nav {
display: flex;
z-index: 50;
background-color: #FFFFFF;
padding: 16px 32px;
}
a {
text-decoration: none;
}
.logo {
display: inline-flex;
}
.animated-logo {
display: flex;
color: #000000;
transition-property: transform;
transition-duration: .15s;
font-size: 35px;
font-weight: 600;
}
.menu a {
color: black;
margin: 0 16px;
font-weight: 300;
text-decoration: none;
transition: 0.2s;
padding: 8px 5px;
border-radius: 99px;
font-size: 20px;
}
.menu a:hover {
color: #808080;
}
<body>
<nav>
<div class="container">
<a href="index.html" class="logo">
<h3 class="animated-logo">
<span class="letter first">t</span>
<span class="letter">a</span>
<span class="letter-hide">a</span>
<span class="letter">r</span>
<span class="letter">s</span>
<span class="letter-hide">t</span>
<span class="letter">r</span>
</h3>
</a>
<div class="menu">
About
Experience
Contact Me
</div>
</div>
</nav>
</body>
EDIT 1
.container {
width: 100vw; /* Added */
max-width: 1280px;
margin: 0 right;
display: flex;
align-items: center;
justify-content: space-between;
}
nav {
display: flex;
z-index: 50;
background-color: #FFFFFF;
padding: 16px 32px;
}
a {
text-decoration: none;
}
.logo {
display: inline-flex;
}
.animated-logo {
display: flex;
color: #000000;
transition-property: transform;
transition-duration: .15s;
font-size: 35px;
font-weight: 600;
}
.menu a {
color: black;
margin: 0 16px;
font-weight: 300;
text-decoration: none;
transition: 0.2s;
padding: 8px 5px;
border-radius: 99px;
font-size: 20px;
}
.menu a:hover {
color: #808080;
}
/* Added */
nav {
display: flex;
justify-content: space-around;
}
<body>
<nav>
<div class="container">
<a href="index.html" class="logo">
<h3 class="animated-logo">
<span class="letter first">t</span>
<span class="letter">a</span>
<span class="letter-hide">a</span>
<span class="letter">r</span>
<span class="letter">s</span>
<span class="letter-hide">t</span>
<span class="letter">r</span>
</h3>
</a>
<div class="menu">
About
Experience
Contact Me
</div>
</div>
</nav>
</body>
EDIT 2
Github 1440px:
Github 2560px:
What I usually use for navbars is a display: flex;
If I understood correctly what you want to do is organise the elements horizontally in the bar, to do that you can give the container class the following properties:
.container {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: space-around;
}
If that doesn't suit your needs or if you want more informations about flex boxes I'd recommend this website: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
It explains all you need to know about flex boxes and could help you find a solution to your problem.
I am currently working on a Forum website, and can't figure out how to place elements that won't be influenced by other elements' content.
For example, if I change the element content text, the other elements that are next to it will change position.
Example:
HTML and CSS from the first image:
.staff-show {
float: right;
margin-right: 10em;
margin-top: 10em;
}
.staff-show .title-staff {
font-family: Poppins-SemiBold, FontAwesome;
display: flex;
align-items: center;
justify-content: center;
}
.staff-show .title-staff i {
margin-right: 1em;
}
.staff-show .title-staff h2 {
right: 5%;
}
.staff-show .staff-list h3,
p {
margin: 0.1em;
padding: 0.1em;
}
.staff-show .staff-list .icon-border {
border: 2px solid #212e38;
border-radius: 10px;
width: 4em;
height: 4em;
display: inline-block;
}
.staff-show .staff-list i {
padding: 1.3em 0.9em;
text-align: center;
}
.staff-show .staff-list ul li {
margin: 1.2em;
}
.staff-show .staff-list .staff-info {
float: right;
margin-left: 1.5em;
}
<div class="staff-show">
<div class="staff-list">
<ul>
<li>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>Johnny Games</h3>
<p>System Admin</p>
</div>
</li>
<li>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>John Lenon</h3>
<p>Service Founder</p>
</div>
</li>
</ul>
</div>
</div>
Second image HTML and CSS:
.forum-list button {
border: 2px solid #212e38;
border-radius: 20px;
padding: 10px 40px;
width: 77em;
height: 8.5em;
font-family: Poppins-SemiBold, FontAwesome;
color: white;
margin-right: 1em;
margin-bottom: 1.5em;
display: grid;
}
.forum-list-border {
border: 2px solid #172129;
border-radius: 20px;
width: 5.7em;
height: 5.7em;
margin-top: 0.3em;
}
.forum-list i {
margin-top: 1.5em;
width: 100%;
}
.forum-list-header {
display: flex;
align-items: center;
}
.forum-list h2 {
margin-left: 2em;
}
.forum-list .forum-list.btn {
margin-bottom: 2em;
}
.forum-list-info {
grid-column-start: 2;
grid-column-end: 3;
}
.forum-list-info-numbers {
display: flex;
align-items: center;
}
.forum-list-info-text {
display: flex;
align-items: center;
}
.forum-list-info-numbers h3 {
margin-right: 6.3em;
}
.forum-list-info-text p {
margin-right: 5em;
}
<div class="forum-container">
<div class="forum-list-container">
<div class="forum-list">
<button class="forum-list-btn">
<div class="forum-list-header">
<div class="forum-list-border"><i class="fa-solid fa-laptop-code fa-2xl"></i></div>
<h2>Tech, Informatique et autres</h2>
</div>
<div class="forum-list-info">
<div class="forum-list-info-numbers"><h3>5.1k</h3><h3>50.3k</h3></div>
<div class="forum-list-info-text"><p>Posts</p><p>Messages</p></div>
</div>
</button>
</div>
</div>
</div>
Sorry for this long code, I just want to make this as explicit as possible, so it's easier to solve.
You can use the display: flex property to achieve both results. I have added another wrapper div for the first image and added a new class on button for the second one.
.staff-show {
float: right;
margin-right: 10em;
margin-top: 10em;
}
.staff-show .title-staff {
font-family: Poppins-SemiBold, FontAwesome;
display: flex;
align-items: center;
justify-content: center;
}
.staff-show .title-staff i {
margin-right: 1em;
}
.staff-show .title-staff h2 {
right: 5%;
}
.staff-show .staff-list h3,
p {
margin: 0.1em;
padding: 0.1em;
}
.staff-show .staff-list .icon-border {
border: 2px solid #212e38;
border-radius: 10px;
width: 4em;
height: 4em;
display: inline-block;
}
.staff-show .staff-list i {
padding: 1.3em 0.9em;
text-align: center;
}
.staff-show .staff-list ul li {
margin: 1.2em;
}
.staff-show .staff-list .staff-info {
float: right;
margin-left: 1.5em;
}
.another-div {
display: flex;
}
<div class="staff-show">
<div class="staff-list">
<ul>
<li>
<div class='another-div'>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>Johnny Games</h3>
<p>System Admin</p>
</div>
</div>
</li>
<li>
<div class='another-div'>
<div class="icon-border"><i class="fa-solid fa-user fa-xl"></i></div>
<div class="staff-info">
<h3>John Lenon</h3>
<p>Service Founder</p>
</div>
</div>
</li>
</ul>
</div>
</div>
.forum-list button {
border: 2px solid #212e38;
border-radius: 20px;
padding: 10px 40px;
width: 77em;
height: 8.5em;
font-family: Poppins-SemiBold, FontAwesome;
color: white;
margin-right: 1em;
margin-bottom: 1.5em;
display: grid;
}
.forum-list-border {
border: 2px solid #172129;
border-radius: 20px;
width: 5.7em;
height: 5.7em;
margin-top: 0.3em;
}
.forum-list i {
margin-top: 1.5em;
width: 100%;
}
.forum-list-header {
display: flex;
align-items: center;
}
.forum-list h2 {
margin-left: 2em;
}
.forum-list .forum-list.btn {
margin-bottom: 2em;
}
.forum-list-info {
grid-column-start: 2;
grid-column-end: 3;
}
.forum-list-info-numbers {
display: flex;
align-items: center;
}
.forum-list-info-text {
display: flex;
align-items: center;
}
.forum-list-info-numbers h3 {
margin-right: 6.3em;
}
.forum-list-info-text p {
margin-right: 5em;
}
.d-flex-between {
display: flex !important;
justify-content: space-between;
}
<div class="forum-container">
<div class="forum-list-container">
<div class="forum-list">
<button class="forum-list-btn d-flex-between">
<div class="forum-list-header">
<div class="forum-list-border"><i class="fa-solid fa-laptop-code fa-2xl"></i></div>
<h2>Tech, Informatique et autres</h2>
</div>
<div class="forum-list-info">
<div class="forum-list-info-numbers">
<h3>5.1k</h3>
<h3>50.3k</h3>
</div>
<div class="forum-list-info-text">
<p>Posts</p>
<p>Messages</p>
</div>
</div>
</button>
<button class="forum-list-btn d-flex-between">
<div class="forum-list-header">
<div class="forum-list-border"><i class="fa-solid fa-laptop-code fa-2xl"></i></div>
<h2>Account Boost</h2>
</div>
<div class="forum-list-info">
<div class="forum-list-info-numbers">
<h3>5.1k</h3>
<h3>50.3k</h3>
</div>
<div class="forum-list-info-text">
<p>Posts</p>
<p>Messages</p>
</div>
</div>
</button>
</div>
</div>
</div>
Your first example does this because the .staff-show .staff-list .staff-info rule is set to float: right. So, when the content in div.staff-info gets smaller, the right side of the div will remain flush with the right side of its container.
Assuming you won't have enough content to force it to wrap, you could simply do the following to keep it left-aligned with the bordered box:
.staff-show .staff-list .staff-info {
display: inline-block;
vertical-align: top;
margin-left: 1.5em;
}
However, I would suggest using a grid layout or a similar technique so that it's less likely to break if your content size or container size changes.
In your second example, just add justify-content: space-between to the .forum-list button rule.
You need to differentiate the class names for example in the first image you have both classes named as staff-info, meaning if you style the staff-info class both divs will change simultaneously.
I started a new electron project(angulat 9 : using scss), currently stuck at making custom title bar. Here is my code:
app.component.html
<div class="container">
<app-titlebar></app-titlebar>
<div id="router_outlet">
<router-outlet></router-outlet>
</div>
</div>
titlebar.component.html
html, body{
margin: 0 ;
padding: 0 ;
width: 100% ;
height: 100% ;
}
.titlebar {
display: flex;
position: relative;
border: 1px solid black ; /* for reference*/
top: 0;
left: 0;
justify-content: space-between;
height: 3rem;
flex-direction: row;
}
.window-button,
.back-button {
font-size: 12pt;
font-weight: lighter;
-webkit-app-region: no-drag;
-webkit-font-smoothing: antialiased;
text-rendering: geometricPrecision;
}
.window-button {
padding-left: 15px;
padding-right: 15px;
}
.back-button {
padding-left: 17px;
padding-right: 17px;
}
#restore {
transform: rotate(180deg);
}
.window,
.navigation {
display: flex;
align-items: center;
}
.normal:hover {
background-color: rgba(0,0,0,0.2);
}
.danger:hover {
background-color: red;
color: white;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="titlebar">
<div class="navigation">
<a class="back-button normal material-icons">arrow_back</a>
<span class="apptitle">Electron-App</span>
</div>
<div class="window">
<a class="window-button normal material-icons">remove</a>
<a *ngIf="showMaximizeButton ; else showRestore" class="window-button normal material-icons">crop_square</a>
<!-- <ng-template #showRestore>
<a class="window-button normal material-icons" id="restore">flip_to_front</a>
</ng-template> -->
<a class="window-button danger material-icons">clear</a>
</div>
</div>
My question is how to fill these <a> tag entirely to their parent div element height so that on hovering these link the background area filled fully to the .titlebar height.
Set their height to full and make them flex too to allow vertical positioning of their content (they are already set to inline-block:
html, body{
margin: 0 ;
padding: 0 ;
width: 100% ;
height: 100% ;
}
.titlebar {
display: flex;
position: relative;
border: 1px solid black ; /* for reference*/
top: 0;
left: 0;
justify-content: space-between;
height: 3rem;
flex-direction: row;
}
.window-button,
.back-button {
font-size: 12pt;
font-weight: lighter;
-webkit-app-region: no-drag;
-webkit-font-smoothing: antialiased;
text-rendering: geometricPrecision;
height: 100%;
display: inline-flex !important;
align-items: center;
}
.window-button {
padding-left: 15px;
padding-right: 15px;
}
.back-button {
padding-left: 17px;
padding-right: 17px;
}
#restore {
transform: rotate(180deg);
}
.window,
.navigation {
display: flex;
align-items: center;
}
.normal:hover {
background-color: rgba(0,0,0,0.2);
}
.danger:hover {
background-color: red;
color: white;
}
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="titlebar">
<div class="navigation">
<a class="back-button normal material-icons">arrow_back</a>
<span class="apptitle">Electron-App</span>
</div>
<div class="window">
<a class="window-button normal material-icons">remove</a>
<a *ngIf="showMaximizeButton ; else showRestore" class="window-button normal material-icons">crop_square</a>
<!-- <ng-template #showRestore>
<a class="window-button normal material-icons" id="restore">flip_to_front</a>
</ng-template> -->
<a class="window-button danger material-icons">clear</a>
</div>
</div>
You could make the anchor tags use display: flex:
.titlebar a,
.window a {
height: 100%;
display: flex;
align-items: center;
}
Here's the working snippet:
html, body{
margin: 0 ;
padding: 0 ;
width: 100% ;
height: 100% ;
}
.titlebar {
display: flex;
position: relative;
border: 1px solid black ; /* for reference*/
top: 0;
left: 0;
justify-content: space-between;
height: 3rem;
flex-direction: row;
}
.titlebar a,
.window a {
height: 100%;
display: flex;
align-items: center;
}
.window-button,
.back-button {
font-size: 12pt;
font-weight: lighter;
-webkit-app-region: no-drag;
-webkit-font-smoothing: antialiased;
text-rendering: geometricPrecision;
}
.window-button {
padding-left: 15px;
padding-right: 15px;
}
.back-button {
padding-left: 17px;
padding-right: 17px;
}
#restore {
transform: rotate(180deg);
}
.window,
.navigation {
display: flex;
align-items: center;
}
.normal:hover {
background-color: rgba(0,0,0,0.2);
}
.danger:hover {
background-color: red;
color: white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.7.5/angular.min.js"></script>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<div class="titlebar">
<div class="navigation">
<a class="back-button normal material-icons">arrow_back</a>
<span class="apptitle">Electron-App</span>
</div>
<div class="window">
<a class="window-button normal material-icons">remove</a>
<a *ngIf="showMaximizeButton ; else showRestore" class="window-button normal material-icons">crop_square</a>
<!-- <ng-template #showRestore>
<a class="window-button normal material-icons" id="restore">flip_to_front</a>
</ng-template> -->
<a class="window-button danger material-icons">clear</a>
</div>
</div>
This question already has answers here:
Center one and right/left align other flexbox element
(11 answers)
Closed 4 years ago.
I'm trying to move the register button from the middle to the right (as see on the following photos) Without it affecting the 3 items in the middle.
So this is what I have:
This is what I'm trying to get:
Here is my code:
body {
background-color: #323642;
}
.menubar {
justify-content: center;
display: flex;
flex-direction: row;
background-color: #272a33;
margin-top: -10px;
margin-left: -10px;
margin-right: -10px;
align-items: center;
height: 100%;
}
.menuitem {
padding: 11px;
padding-top: 17px;
padding-left: 29px;
font-size: 22px;
font-family: "Ostrich Sans";
color: #ee5f95;
text-decoration: none;
}
#login_button {
margin-top: 2px;
border-radius: 5px;
background-color: #ee5f95;
width: 100px;
height: 34px;
text-align: center;
border: none;
font-family: "Ostrich Sans";
font-size: 22px;
color: white;
line-height: 33px;
transition: 0.7s;
justify-content: flex-end;
}
#login_button:hover {
width: 110px;
background-color: #ae466d;
transition: 0.7s;
}
<head lang="Eng">
<meta charset="UTF-8">
<title>test </title>
</head>
<body>
<div class="menubar" id="hey">
<a class="menuitem" id="firstmenuitem" href="./buy_sell.html">Buy & Sell</a>
<a class="menuitem" href="./exchange.html">Exchange</a>
<a class="menuitem" href="./events.html">Events</a>
<div id="delimeter"></div>
<button id="login_button">Register</button>
</div>
</body>
I have tried adding margin-right:auto; though it just completly shifter the button to the right and didn't leve any space between it and the window. I have also tried adding justify-content: space-between; but it didn't give me what I wanted. if anyone could help that would be greatly appreciated!
you can put the position of the button absolute like this :
#login_button {
position: absolute;
right: 10px;
margin-top: 2px;
border-radius: 5px;
background-color: #ee5f95;
width: 100px;
height: 34px;
text-align: center;
border: none;
font-family: "Ostrich Sans";
font-size: 22px;
color: white;
line-height: 33px;
transition: 0.7s;
justify-content: flex-end;
}
https://jsfiddle.net/fh3cj02d/
You could use a flexbox inside a flexbox like this
body {
background-color: #323642;
}
.menubar {
display: flex;
flex-direction: row;
background-color: #272a33;
margin-top: -10px;
margin-left: -10px;
margin-right: -10px;
height: 100%;
}
.left {
flex: 1;
}
.middle {
display: flex;
}
.right {
flex: 1;
display: flex;
flex-direction: row-reverse;
align-items: center;
}
.menuitem {
padding: 11px;
padding-top: 17px;
padding-left: 29px;
font-size: 22px;
font-family: "Ostrich Sans";
color: #ee5f95;
text-decoration: none;
}
#login_button {
margin-top: 2px;
margin-right: 10px;
border-radius: 5px;
background-color: #ee5f95;
width: 100px;
height: 34px;
text-align: center;
border: none;
font-family: "Ostrich Sans";
font-size: 22px;
color: white;
line-height: 33px;
transition: 0.7s;
}
#login_button:hover {
width: 110px;
background-color: #ae466d;
transition: 0.7s;
}
<html>
<head lang="Eng">
<meta charset="UTF-8">
<title>test </title>
</head>
<body>
<div class="menubar" id="hey">
<div class="left"></div>
<div class="middle">
<a class="menuitem" id="firstmenuitem" href="./buy_sell.html">Buy & Sell</a>
<a class="menuitem" href="./exchange.html">Exchange</a>
<a class="menuitem" href="./events.html">Events</a>
<div id="delimeter"></div>
</div>
<div class="right">
<button id="login_button">Register</button>
</div>
</div>
</body>
</html>
I like this because it's purely flexbox, no absolute positioning or margin auto. Also the .middle div is naturally centered this way.
One way to accomplish this is to make the left margin of the first and last item auto. In this example, you would apply a left margin to .menuitem:last-of-type and #login_button.
body {
background-color: #323642;
}
.menubar {
justify-content: center;
display: flex;
flex-direction: row;
background-color: #272a33;
margin-top: -10px;
margin-left: -10px;
margin-right: -10px;
align-items: center;
height: 100%;
}
.menuitem {
padding: 11px;
padding-top: 17px;
padding-left: 29px;
font-size: 12px;
font-family: "Ostrich Sans";
color: #ee5f95;
text-decoration: none;
}
.menuitem:first-of-type {
margin-left: auto; /* NEW */
}
#login_button {
margin-left: auto; /* NEW */
margin-top: 2px;
border-radius: 5px;
background-color: #ee5f95;
width: 100px;
height: 34px;
text-align: center;
border: none;
font-family: "Ostrich Sans";
font-size: 12px;
color: white;
line-height: 33px;
transition: 0.7s;
justify-content: flex-end;
}
#login_button:hover {
width: 110px;
background-color: #ae466d;
transition: 0.7s;
}
<body>
<div class="menubar" id="hey">
<a class="menuitem" id="firstmenuitem" href="./buy_sell.html">Buy & Sell</a>
<a class="menuitem" href="./exchange.html">Exchange</a>
<a class="menuitem" href="./events.html">Events</a>
<div id="delimeter"></div>
<button id="login_button">Register</button>
</div>
</body>
I think you can just edit your body this way:
<body>
<div class="menubar" id="hey">
<a class="menuitem" id="firstmenuitem" href="./buy_sell.html">Buy & Sell</a>
<a class="menuitem" href="./exchange.html">Exchange</a>
<a class="menuitem" href="./events.html">Events</a>
<div id="delimeter"></div>
<button class="festa" id="login_button">Register</button>
</div>
and add this css class:
.festa {
position: absolute;
right: 0px;
}
This will keep the 3 buttons in the perfect center of the screen and the register one to the right, but they will overlap onto small screens.
This is the fiddle: https://jsfiddle.net/5xbnhkcr/
Otherwise you can play with flexbox weights (this is similar to your desired result)
modify body this way:
<body>
<div class="menubar" id="hey">
<div class="buttons">
<a class="menuitem" id="firstmenuitem" href="./buy_sell.html">Buy & Sell</a>
<a class="menuitem" href="./exchange.html">Exchange</a>
<a class="menuitem" href="./events.html">Events</a>
<div id="delimeter"></div>
</div>
<button class="festa" id="login_button">Register</button>
</div>
and add those css classes:
.buttons {
flex: 9;
justify-content: center;
display: flex;
flex-direction: row;
}
.festa {
flex: 1;
}
Using flex: 9; and flex: 1; will divide the div into 10 parts.
The part containing the 3 buttons will occupy 9/10 of the width and the register button 1/10.
here's the fiddle: https://jsfiddle.net/e5hp2v7L/
I have this sample:
link
CODE HTML:
<div class="row">
<div class="col-md-push-8 col-md-4 small-menu">
List your Property
<ul class="list-inline">
<li>Travelor Login</li>
<li>Owner Login</li>
</ul>
</div>
</div>
CODE CSS:
.small-menu .orange-menu {
background: #ed7103;
font-size: 18px;
padding: 18px;
font-weight: 500;
}
a{
display: inline-block;
}
.small-menu .list-inline {
overflow: auto;
background: rgba(31,106,138,0.7);
margin: 0px;
vertical-align: bottom;
display: inline-block;
padding: 14px;
}
How can I make div (".small-menu .list-inline") to occupy all the remaining space until the end?
I want to keep elements of the same height and position
Can you help me to solve this problem?
Thanks in advance!
Flexbox can do that:
.small-menu {
display: flex;
align-items: flex-end;
}
.small-menu .orange-menu {
background: #ed7103;
font-size: 18px;
padding: 18px;
font-weight: 500;
}
.small-menu .list-inline {
overflow: auto;
background: rgba(31, 106, 138, 0.7);
margin: 0px;
vertical-align: bottom;
flex: 1;
display: flex;
align-items: center;
padding: 14px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="row">
<div class="col-md-push-8 col-md-4 small-menu">
List your Property
<ul class="list-inline">
<li>Travelor Login
</li>
<li>Owner Login
</li>
</ul>
</div>
</div>