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;
}
}
Related
So I'm trying to make an easy website for a server user ordering stuffs. But now I have a problem that will affect about the Navigator text.
Now it's looks like this:
As you can see in the code below, there should be a navigator text above the Back button and also the Categories button below should be shows like the back and prices button above too since they're the same code.
I tried for some other way but it's kinda out my coding range so I decide to find on Google but I don't find any helpful solve.
Is that actually can be fix?
Conclusion: problem
"Navigator" text disappear at 100% zoom view
Category buttons can't shows like buttons above (same codes as buttons above but different ID)
.title {
color: #66d4ff;
background-color: #444444;
font-size: 62px;
text-align: center;
border: solid 10px #66d4ff;
padding: 50px;
margin-left: 302px;
}
body {
background: #444444;
}
button {
color: #66d4ff;
background: #444444;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
}
a {
color: #66d4ff
}
nav {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 100%;
background: #4a4a4a;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border-right: solid 2px #ffffff;
overflow-y: scroll;
}
.nav::-webkit-scrollbar {
display: hidden;
}
main {
color: #66d4ff;
background-color: #444444;
font-size: 20px;
}
.navigator {
display: block;
margin-bottom: 50px;
color: #66d4ff;
font-size: 35px;
text-align: center;
}
.store {
padding: 0 99.5px 0 99.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.prices {
padding: 0 93.5px 0 93.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Woods {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Stones {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Brewing {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Enchanting {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Color {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Nether {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.Redstone {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
<main>
<div class="title">
<t1>MineGlobe | IchorDragon's Store</t1>
</div>
</main>
<nav>
<div id="navigator">
<p class="navigator">Navigator</p>
<div>
<button class="store">Back</button>
<button class="prices">Prices</button>
</div>
</div>
<div id="category">
<p class="navigator">Select Category</p>
<div>
<button class="Woods" onclick="document.getElementById('Woods').scrollIntoView();"><a style="text-decoration: none;">Woods</a></button>
<button class="Stones" onclick="document.getElementById('Stones').scrollIntoView();"><a style="text-decoration: none;">Stones</a></button>
<button class="ArmorsWeapon" onclick="document.getElementById('ArmorsWeapon').scrollIntoView();"><a style="text-decoration: none;">Armors & Weapons</a></button>
<button class="Brewing" onclick="document.getElementById('Brewing').scrollIntoView();"><a style="text-decoration: none;">Brewing</a></button>
<button class="Enchanting" onclick="document.getElementById('Enchanting').scrollIntoView();"><a style="text-decoration: none;">Enchanting</a></button>
<button class="Color" onclick="document.getElementById('Color').scrollIntoView();"><a style="text-decoration: none;">Color</a></button>
<button class="Redstone" onclick="document.getElementById('Redstone').scrollIntoView();"><a style="text-decoration: none;">Redstone</a></button>
<button class="Nether" onclick="document.getElementById('Nether').scrollIntoView();"><a style="text-decoration: none;">Nether</a></button>
</div>
</div>
</nav>
I honestly can't explain all the changes made, there are too many. My attempt was to clean up your code and give you a working layout (hopefully that's what you were looking for).
In 2021 there are better layouts compared to fixed menu (with grids for example), which work better in responsive and are more clean. But it would require an in-depth study that's up to you.
body {
background-color: #444444;
}
main {
width: 100%;
padding-left: 302px;
box-sizing: border-box;
overflow:hidden;
color: #66d4ff;
background-color: #444444;
font-size: 20px;
}
.title {
padding: 50px;
border: solid 10px #66d4ff;
font-size: 62px;
text-align: center;
}
nav {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 100%;
background-color: #4a4a4a;
border-right: solid 2px #ffffff;
overflow-y: scroll;
color: #66d4ff;
}
.navigator {
display: block;
margin-bottom: 50px;
font-size: 35px;
text-align: center;
}
button {
width:96%;
margin: 10px auto;
background: #444444;
color: #66d4ff;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
cursor:pointer;
}
<body>
<main>
<div class="title">
<t1>MineGlobe | IchorDragon's Store</t1>
</div>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/> This is a long page content...
<br/>
</main>
<nav>
<div id="navigator">
<p class="navigator">Navigator</p>
<div>
<button>Back</button>
<button>Prices</button>
</div>
</div>
<div id="category">
<p class="navigator">Select Category</p>
<div>
<button class="Woods items" onclick="document.getElementById('Woods').scrollIntoView();">Woods</button>
<button class="Stones items" onclick="document.getElementById('Stones').scrollIntoView();">Stones</button>
<button class="ArmorsWeapon items" onclick="document.getElementById('ArmorsWeapon').scrollIntoView();">Armors & Weapons</button>
<button class="Brewing items" onclick="document.getElementById('Brewing').scrollIntoView();">Brewing</button>
<button class="Enchanting items" onclick="document.getElementById('Enchanting').scrollIntoView();">Enchanting</button>
<button class="Color items" onclick="document.getElementById('Color').scrollIntoView();">Color</button>
<button class="Redstone items" onclick="document.getElementById('Redstone').scrollIntoView();">Redstone</button>
<button class="Nether items" onclick="document.getElementById('Nether').scrollIntoView();">Nether</button>
</div>
</div>
</nav>
</body>
"Navigator" text disappear: This is because justify-content: center; on the nav
Buttons will not take a width of 100% even with display: block (more information), so it needs to be added. Note that since all cathegories have the same code a single class is enough.
.title {
color: #66d4ff;
background-color: #444444;
font-size: 62px;
text-align: center;
border: solid 10px #66d4ff;
padding: 50px;
margin-left: 302px;
}
body {
background: #444444;
}
button {
color: #66d4ff;
background: #444444;
font-size: 30px;
font-family: 'Times New Roman', Times, serif;
}
a {
color: #66d4ff
}
nav {
position: fixed;
top: 0;
left: 0;
width: 300px;
height: 100%;
background: #4a4a4a;
display: flex;
flex-direction: column;
align-items: center;
/* justify-content: center; */
border-right: solid 2px #ffffff;
overflow-y: scroll;
}
.nav::-webkit-scrollbar {
display: hidden;
}
main {
color: #66d4ff;
background-color: #444444;
font-size: 20px;
}
.navigator {
display: block;
margin-bottom: 50px;
color: #66d4ff;
font-size: 35px;
text-align: center;
}
.store {
padding: 0 99.5px 0 99.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.prices {
padding: 0 93.5px 0 93.5px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
}
.category {
padding: 0 80px 0 80px;
display: block;
margin-top: 25px;
margin-bottom: 25px;
width: 100%;
}
<main>
<div class="title">
<t1>MineGlobe | IchorDragon's Store</t1>
</div>
</main>
<nav>
<div id="navigator">
<p class="navigator">Navigator</p>
<div>
<button class="store">Back</button>
<button class="prices">Prices</button>
</div>
</div>
<div id="category">
<p class="navigator">Select Category</p>
<div>
<button class="category Woods" onclick="document.getElementById('Woods').scrollIntoView();"><a style="text-decoration: none;">Woods</a></button>
<button class="category Stones" onclick="document.getElementById('Stones').scrollIntoView();"><a style="text-decoration: none;">Stones</a></button>
<button class="category ArmorsWeapon" onclick="document.getElementById('ArmorsWeapon').scrollIntoView();"><a style="text-decoration: none;">Armors & Weapons</a></button>
<button class="category Brewing" onclick="document.getElementById('Brewing').scrollIntoView();"><a style="text-decoration: none;">Brewing</a></button>
<button class="category Enchanting" onclick="document.getElementById('Enchanting').scrollIntoView();"><a style="text-decoration: none;">Enchanting</a></button>
<button class="category Color" onclick="document.getElementById('Color').scrollIntoView();"><a style="text-decoration: none;">Color</a></button>
<button class="category Redstone" onclick="document.getElementById('Redstone').scrollIntoView();"><a style="text-decoration: none;">Redstone</a></button>
<button class="category Nether" onclick="document.getElementById('Nether').scrollIntoView();"><a style="text-decoration: none;">Nether</a></button>
</div>
</div>
</nav>
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...
I am not an expert in CSS, but I am trying to add a title next to Profile Image and Name as per the pic added
I am trying to send the text next to the profile name and image and enlarge the font but I think there is something wrong with the CSS so can I override the CSS and write it directly in the HTML or what is the best way to do it
here is the HTML
<div class="dcard_header" style:"display: inline-block;">
<div class="profile_image" href="{% url 'score:user-posts' post.designer.username %}">
<img class="profile_image" src="{{ post.designer.profile.image.url }}">
</div>
<div class="post_info">
<a class="post_name" href="{% url 'score:user-posts' post.designer.username %}">{{ post.designer }}</a>
</div>
<div class="caption" style="text-align:center;">
<strong><span><p>{{post.title}}</p></span></strong>
</div>
</div>
This is the CSS
.dcard {
background-color: #ffff;
margin: 0 auto;
width: 614px;
height: auto;
border: 0.8px solid #ccc;
border-radius: 4px;
margin-bottom: 20px;
}
.dcard_header {
padding: 10px;
display: inline-block;
}
.dcard_header a {
text-decoration: none;
color: black;
}
.profile_image {
display: inline-block;
height: 40px;
width: 40px;
padding: 0;
margin: 0;
border: 0 solid #000000;
border-radius: 50%;
}
.post_info {
display: inline-block;
padding-left: 14px;
}
.caption {
display: inline-block;
width: 100%;
padding: 0px 16px;
}
.caption a {
font-weight: bold;
color: #000;
text-decoration: none;
display: inline-block;
padding-left: 5px;
margin-left: -5px;
padding-right: 5px;
}
.caption span {
font-size: 18px;
color: #111;
display: inline-block;
margin-right: 15px;
display: inline-block;
}
Thanks all
Rather than inline-block, you can try using flex.
should It, fix:
.dcard_header {
padding: 10px;
display: flex;
}
I am developing an angular 2 app with angular material. I have two buttons sign in and sign up I want a vertical line between the two buttons; I saw many examples on different sites but it doesn't work. I want that the buttons be on same line (inline and between them a little vertical line).
this is the html code :
.textAlign {
text-align: center;
color: white;
position: absolute;
top: 50%;
left: 50%;
/* à 50%/50% du parent référent */
transform: translate(-50%, -50%);
font-family: 'Source Sans Pro';
}
h1 {
font-weight: bold;
}
.image {
width: 100%;
}
.ligne_verticale {
width: 5px;
border-left: 5px solid gray;
height: 70px;
}
.nav-button {
text-align: center;
vertical-align: middle;
border: solid 1px;
border-radius: 5px;
background-color: white;
font-weight: bold;
width: 120px;
margin-right: 10%;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div class="content">
<div>
<img class="image" src="http://seabramota.com/img/intro-bg.jpg" alt="image
d'accueil">
<div class="textAlign">
<h1>{{ 'PAGEHOME.TITLE' | translate }}</h1>
<br>
<h3>{{ 'PAGEHOME.DESCRIPTION' | translate }}</h3>
<br>
<button mat-button color="primary" class="nav-button" (click)="openConnectDialog()">
{{ 'PAGEHOME.CONNECTBUTTON' | translate }}
</button>
<button mat-button color="primary" class="nav-button" (click)="
openRegisterDialog()">
{{ 'PAGEHOME.INSCRIREBUTTON' | translate }}
</button>
</div>
</div>
Something like that ?
.container {
display: flex;
width: 100%;
justify-content: center;
}
button {
background: #99A3FF;
color: white;
border: 0;
padding: 6px 12px;
border-radius: 2px;
}
.button-container {
padding: 12px 24px;
}
.button-container:not(:last-child) {
border-right: 1px solid #ddd;
}
<div class="container">
<div class="button-container"><button>Register</button></div>
<div class="button-container"><button>Log In</button></div>
</div>
I am making a website with a navigation menu on the top. I have multiple buttons with dropdown menus. I want to make the buttons in all in a row at the same height and I want the buttons to be in the middle. Here is my code:
/* Links CSS */
a,
a:visited,
a:active {
text-decoration: underline;
color: white;
}
a:hover {
color: red;
text-decoration: underline;
}
/* Element CSS */
html,
body {
margin: 0px;
background-color: white;
}
html {
height: 100%;
width: 100%;
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
position: relative;
padding-bottom: 6rem;
min-height: 100%;
}
.button,
.games,
.programs,
.apps,
.misc {
font-family: 'Arsenal';
font-size: 18px;
text-decoration: underline;
background: transparent;
padding-top: 1%;
padding-bottom: 1%;
padding-left: 1.5%;
padding-right: 1.5%;
cursor: pointer;
border: 0px;
}
.content {
font-family: 'Arsenal';
font-size: 15px;
text-decoration: none;
background-color: white;
border: 0px;
cursor: pointer;
}
.button:hover,
.content:hover,
.games:hover,
.programs:hover,
.apps:hover,
.misc:hover {
background-color: #f0efef;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1;
padding: 0.5%;
}
.games-dropdown {
position: relative;
display: inline-block;
}
.progams-dropdown {
position: relative;
display: inline-block;
}
.apps-dropdown {
position: relative;
display: inline-block;
}
.misc-dropdown {
position: relative;
display: inline-block;
}
.show {
display: block;
}
/* Div CSS */
#page {
margin-top: 0px;
}
#title {
font-family: 'Arsenal';
font-size: 37px;
padding-top: 0.5%;
color: black;
display: inline-block;
cursor: pointer;
}
#links {
margin: auto;
display: inline-block;
overflow: auto;
}
#content {
background-color: white;
border: 1px solid black;
border-radius: 3px;
margin-left: 10%;
margin-right: 10%;
box-shadow: 1px 1.5px #8f8f8f;
}
#footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 1rem;
background-color: #f0efef;
text-align: center;
border-top: 1px solid black;
font-family: 'Arsenal';
font-size: 15px;
}
<!-- HTML -->
<center>
<div id="links">
<!-- Code For Dropdown Menus | Code From http://www.w3schools.com/ | Thanks To Them!-->
<!-- Games Dropdown Menu: Browser and Downloadable-->
<div class="programs-dropdown">
<button class="programs" onclick="games()" title="Games">Games</button>
<div id="gamesDropdown" class="dropdown-content">
<button class="content" onclick="download()">Download</button>
<button class="content" onclick="online()">Online</button>
</div>
</div>
<!-- Programs Dropdown Menu: Windows and Max OS X-->
<div class="programs-dropdown">
<button class="programs" onclick="programs()" title="Programs">Programs</button>
<div id="programsDropdown" class="dropdown-content">
<button class="content" onclick="windows()">Windows</button>
<button class="content" onclick="mac()">Mac OS X</button>
</div>
</div>
<button class="button" onclick="websites()" title="Websites">Websites</button>
<button class="button" onclick="home()" title="Home">Home</button>
<!-- Apps Dropdown Menu: IOS and Android -->
<div id="apps-dropdown">
<button class="apps" onclick="apps()" title="Apps">Apps</button>
<div id="appsDropdown" class="dropdown-content">
<button class="content" onclick="ios()">IOS</button>
<button class="content" onclick="android()">Android</button>
</div>
</div>
<button class="button" onclick="blog()" title="Blog">Blog</button>
<!-- Misc. Dropdown Menu: Chrome Extensions, GitHub, Etc.-->
<div id="misc-dropdown">
<button class="misc" onclick="misc()" title="Misc.">Misc.</button>
<div id="miscDropdown" class="dropdown-content">
<button class="content" onclick="chrome()">Chrome Extensions</button>
<button class="content" onclick="github()">GitHub</button>
</div>
</div>
</div>
</center>
The easiest way to center elements is to use flexbox.
You can learn about it more at: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Using flexbox to center elements is actually quite simple. Assuming you have set of elements:
<div class="elements">
<div class="element__item">Element one</div>
<div class="element__item">Element two</div>
<div class="element__item">Some other element</div>
</div>
You can center them horizontally & vertically using css like this:
.elements {
display: flex;
justify-content: center;
align-items: center;
}
You can check this on JSfiddle: https://jsfiddle.net/kf405784/