Hello I am trying to make a hamburger menu bar. But I can't seem to position the circle right icon to the right. When I try to add a padding-right it won't let me.
My JS:
{
SidebarData.map((item, index) => {
return (
<div >
<li key={index} className={item.cName}>
<Link to={item.path}>
{item.icon}
<span>{item.title}</span>
<span className={"roundright"}>
<PageRight />
</span>
</Link>
</li>
</div>
);
})
}
My CSS:
.nav-text {
display: flex;
justify-content: center;
align-items: center;
padding: 8px 16px 8px 16px;
list-style: none;
height: 50px;
text-align: center;
}
.nav-text a {
text-decoration: none;
color: #FFFFFF;
border: 1px solid white;
font-size: 14px;
width: 90%;
height: 100%;
display: flex;
align-items: center;
padding: 0 16px;
border-radius: 4px;
}
.roundright {
font-size: 14px;
color: #E7135D;
font-size: 14px;
align-items: center;
padding: 0 16px;
border-radius: 4px;
}
Here is what I currently have:
Desired result:
Here is my CSS:
I would recommend using a flexbox and the justify-content for this case. You can view more on the space-between property here. Note that my answer only contains new classes and not your previously written classes.
Example HTML:
<div >
<Link to={item.path}>
<li key={index} className={`${item.cName} item-container`}>
{item.icon}
<span>{item.title}</span>
<span className={"roundright"}>
<PageRight />
</span>
</li>
</Link>
</div>
Example CSS:
.item-container {
display: flex;
justify-content: space-between;
align-items: center;
}
Related
I m customising angular material for my project.
I m facing alignment issues with padding-left
My Result:
Expected result:
And here is my code:
.mat-flat-button {
line-height: 28px !important;
padding: 0 12px !important;
font-weight: 400 !important;
}
<button mat-flat-button color="primary">
<mat-icon color="white">add</mat-icon>
Create
</button>
Put the button text in a span tag and add the following properties to it:
button {
display: flex;
flex-direction: row;
align-items: center;
background: blue;
color: white;
border: none;
border-radius: 5px;
padding-right: 12px;
}
<button mat-flat-button color="primary">
<mat-icon color="white">add</mat-icon>
<span>Create</span>
</button>
Edit:
Changes in the code are done to run this snippet on this website:
Replacing <mat-icon color="white">add</mat-icon> with <span color="white" class="material-icons">add</span> (Credits: krmld)
button {
display: flex;
flex-direction: row;
align-items: center;
background: blue;
color: white;
border: none;
border-radius: 5px;
padding-right: 12px;
}
<head>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>
<body>
<button mat-flat-button color="primary">
<span color="white" class="material-icons">add</span>
<span>Create</span>
</button>
</body>
I solved it using the following css styles
.mat-button,
.mat-flat-button {
padding: 0 12px !important;
line-height: 28px !important;
font-weight: 400 !important;
font-size: small !important;
}
.mat-icon {
height: inherit !important;
width: inherit !important;
}
.mat-flat-button>.mat-button-wrapper>mat-icon {
margin-left: -4px !important;
margin-right: 4px !important;
font-size: large !important;
}
.mat-button-toggle-label-content {
line-height: 20px !important;
}
Hello, I created a site but I have a problem with my buttons I think
it comes largely from the fact that I use <a> tags (impossible for
me to create from scratch starting from a tag If someone can
explain to me this way of doing things I'm interested because I've
tried many times and it's impossible for me now
I want this style of button : 1) Invite & Support button: https://i.imgur.com/U4wF4H7.png 2) Login Button in the header section:
https://i.imgur.com/rajn8eU.png But i have this style actually :
https://i.imgur.com/xbDuOe3.png
```<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Poseidon | The Perfect Discord Bot</title>
<link rel="stylesheet" href="main.css">
<link rel="icon" type="image/svg+xml" href="img/favicon.svg">
</head>
<body>
<header class="topbar">
<img class="header-logo" src="img/logo.svg" alt="Poseidon Logo" href="index.html">
<nav>
<div class="middle">
Invite
Commands
Documentation
Premium
Support
</div>
<div class="login">
Login
</div>
</nav>
</header>
<div class="circuit">
<h1 class="header_title">The Perfect <br>Discord Music Bot.</h1>
<h2 class="header_second_title">Poseidon is the only Discord bot you'll ever need!</h2>
Invite
Support
</div>
<div class="dark">
<h1>The Perfect Discord Bot.</h1>
<h2>Poseidon is the only Discord bot you'll ever need!</h2>
<h1>The Perfect Discord Bot.</h1>
<h2>Poseidon is the only Discord bot you'll ever need!</h2>
<h1>The Perfect Discord Bot.</h1>
<h2>Poseidon is the only Discord bot you'll ever need!</h2>
</div>
<div class="circuit">
<h1>The Perfect Discord Bot.</h1>
<h2>Poseidon is the only Discord bot you'll ever need!</h2>
</div>
<div id="footer">
<div class="logo">
<div class="flex">
<img class="img" src="img/logo.svg" alt="Poseidon Logo" href="index.html">
</div>
<div class="copyright">© Poseidon Bot 2012 - All Rights Reserved.</div>
</div>
<ul class="product">
<li><b>Product</b></li>
<li>Invite</li>
<li>Commands</li>
<li>Premium</li>
</ul>
<ul class="resources">
<li><b>Resources</b></li>
<li>Docs</li>
<li>Provacy</li>
<li>Refunds</li>
</ul>
<ul class="business">
<li><b>Business</b></li>
<li>Contact</li>
</ul>
<div class="design">
designed with <span style="color: red;">❤</span> by <span style="color: #00e09d;">My Discord
ID</span></div> <!-- Javascript clickable text // add function js -->
<div class="social">
<img src="https://img.icons8.com/material-sharp/24/ffffff/github.png" href="https://google.fr" />
<img src="https://img.icons8.com/material-sharp/24/ffffff/discord-logo.png" href="#" />
<img src="https://img.icons8.com/android/24/ffffff/twitter.png" href="#" />
</div>
</div>
</body>
</html>```
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body, html {
font-size: 16px;
color: rgba(0, 0, .87);
font-family: "Montserrat", sans serif;
line-height: 1.6;
margin: 0;
padding: 0;
font-weight: 500;
width: 100%;
}
.topbar {
height: 80px;
box-shadow: 0 8px 15px rgba(0, 0, 0, .05);
display: flex;
align-items: center;
width: 100%;
background-image: url(img/background.svg);
background-color: rgba(62,62,62, 1);
}
.topbar nav {
display: flex;
width: 100%;
}
.middle {
margin: 0 auto;
}
.topbar nav a {
color: #9F9F9F;
text-decoration: none;
font-weight: 500;
padding: 0 20px;
display: inline-block;
text-align: center;
font-size: 21px;
}
.topbar nav a:hover, .topbar nav a.active {
color: #94C8D0;
}
.header-logo {
padding: 0px 20px;
cursor: pointer;
width: 25vh;
}
.login_btn {
margin: auto 25px auto;
background-color: #EEEEEE;
color: #3b3b3b;
}
.circuit {
background-image: url(img/background.svg);
background-color: rgba(62,62,62, 1);
padding: 192px 0 112px;
}
.dark {
background-color: rgb(35,35,35);
padding: 192px 0 192px;
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
}
.header_title {
text-align: center;
color: #ffffff;
font-family: 'Inter', sans-serif;
font-weight: 1000;
font-size: 72px;
word-spacing: 0px;
margin: 0px;
padding: 0px;
letter-spacing: normal;
line-height: 72px;
}
.header_second_title {
text-align: center;
color: #9F9F9F;
font-family: 'Inter';
font-size: 30px;
margin: 16px 0px 0px;
padding: 0px;
line-height: 36px;
font-weight: 500;
}
.header_btn {
display: flex;
justify-content: space-evenly;
}
.invite_btn {
display: flex;
justify-content: center;
font-size: 24px;
font-family: 'Inter';
background-color: #1A9BB6;
color: #ffffff;
border: none;
text-align: center;
text-decoration: none;
padding: 15px 32px;
}
.support_btn {
display: flex;
justify-content: center;
font-size: 24px;
font-family: 'Inter';
background-color: #EEEEEE;
color: #282828;
border: none;
text-align: center;
text-decoration: none;
padding: 15px 32px;
}
h1 {
text-align: center;
color: #9F9F9F;
}
h2 {
text-align: center;
color: #9F9F9F;
}
#footer {
font-family: sans-serif;
display: grid;
height: 20%;
background-color: black;
color: white;
grid-template-rows: 1fr;
grid-template-columns: 2fr .6fr .6fr 1fr;
grid-template-areas: "logo product resources business"
"social . . design";
}
li {
list-style: none;
padding-top: 8%;
font-size: .9em;
line-height: 1px;
}
.flex {
display: flex;
}
#footer li a {
color: rgb(22,145,176);
text-decoration: none;
}
.logo {
display: flex;
flex-direction: column;
justify-content: flex-start;
grid-area: logo;
padding-left: 1rem;
padding-top: .5rem;
}
.img {
padding-top: .5rem;
width: 25vh;
cursor: pointer;
}
.logo h4 {
line-height: 1rem;
margin-left: 2rem;
}
.copyright {
padding-top: .3rem;
font-size: 1em;
color: rgb(97,97,97);
}
.product {
grid-area: product;
font-size: 20px;
padding-top: .5rem;
}
.resources {
grid-area: resources;
font-size: 20px;
padding-top: .5rem;
}
.business {
grid-area: business;
font-size: 20px;
padding: 8px 0px 0px;
}
.social {
grid-area: social;
padding-top: 1em;
padding-left: 1em;
cursor: pointer;
}
.design {
grid-area: design;
font-size: 1em;
text-align: right;
To train myself, I decided to reproduce this website:
https://hydra.bot/ this project taught me many things despite the fact
that my current project does not correspond to 100% (Very complex for
me to reproduce it to 100% currently), I block especially on the
buttons, so if someone can help me I'm interested, thank you in
advance
You need to wrap your invite and support button in another div that has display flex property.
If you make display flex it is not going to do anything to itself, rather it modifies its child components
.container {
display: flex;
justify-content: center;
}
<div class='container'>
Invite
Support
</div>
I was trying to make the homepage layout for a project that I'm doing with the help of a course and they SCSS to style their Reactjs. But the layout isn't the same to the one in the course even after using the exact same styling. So, please help me out.
Thanks in advance.
Expected :
Result :
Here's the styling :
.homepage {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px 80px;
}
.directory-menu {
width: 100%;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.menu-item {
min-width: 30%;
height: 240px;
flex: 1 1 auto;
display: flex;
align-items: center;
justify-content: center;
border: 1px solid black;
margin: 0 7.5px 15px;
&:first-child {
margin-right: 7.5px;
}
&:last-child {
margin-left: 7.5px;
}
.content {
height: 90px;
padding: 0 25px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
border: 1px solid black;
.title {
font-weight: bold;
margin-bottom: 6px;
font-size: 22px;
color: #4a4a4a;
}
.subtitle {
font-weight: lighter;
font-size: 16px;
}
}
}
Here's the code :
<div className='homepage'>
<div className='directory-menu'>
<div className= 'menu-item'>
<div className='content'>
<h1 className='title'>HATS</h1>
<span className='subtitle'>SHOP NOW</span>
</div>
</div>
</div>
.
.
.
.
</div>
What you have works. It's a dynamic layout so your viewing width effects it; resize the browser and you'll see:
https://codesandbox.io/s/nifty-kalam-1bx9t?file=/src/styles.scss
is it possible to wrap text in flex within a fixed width container?
so it looks like
img username added
you as a friend
rather than
user added
img name you as
a
friend
I can do this if the image and a were separate, but since they both link to the same thing, I wanna see if it can be done in the same tag.
ul {
width: 150px;
height: 300px;
border: solid 1px #000;
}
li {
display: flex;
align-items: center;
justify-content: center;
}
li img {
width: 25px;
height: 25px;
}
li a {
display: flex;
align-items: center;
text-decoration: none;
}
li span {
margin: 0 8px;
}
<ul>
<li>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/350x150"> <span> Username </span>
</a>
<p> added you as a friend</p>
</li>
</ul>
ul {
width: 150px;
height: 300px;
border: solid 1px #000;
padding: 5px;
}
li {
display: flex;
align-items: center;
justify-content: center;
}
li img {
width: 25px;
height: 25px;
}
li a {
display: flex;
align-items: center;
text-decoration: none;
}
li span {
margin: 0 8px;
}
<ul>
<li>
<a href="https://placeholder.com">
<img src="http://via.placeholder.com/350x150"> <span> Username </span>
</a>
<p> added you as a friend</p>
</li>
</ul>
Maybe the flex-wrap property would be useful in your case. Check this link for more information
https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap
I'm trying to replicate this design for my logo but struggling with the CSS. So far I have managed to write the code below but am struggling to create the stacked text for growth hacker and entrepreneur. If you have any guidance it would be much appreciated.
<a class="navbar-brand navbar-brand-fix" href="<?php echo site_url('/') ?>">Elliott Davidson | <span class="logo-growth-hacker">Growth Hacker</span><br><span class="logo-entrepreneur">Entrepreneur</span></a>
.navbar-brand
font-weight: bold
font-size: 1rem
text-transform: uppercase
color: $light-grey
padding: 30px 30px 30px 0px
.navbar-default .navbar-brand
color: $light-grey
a.navbar-brand.navbar-brand-fix
span.logo-growth-hacker
font-weight: 200
font-size: 0.5em
text-transform: none
vertical-align: text-top
span.logo-entrepreneur
font-weight: 200
font-size: 0.5em
text-transform: none
margin-top: -18px
float: inherit
margin-left: 182px
padding-top: 5px
Here's how I would do it. Create a couple of flex columns using the row layout and style accordingly.
a {
display: inline-flex;
align-items: center;
background: linear-gradient(to right, #666, #666 50%, #444 50%, #444);
color: white;
padding: 1rem;
text-decoration: none;
font-size: 1.25rem;
}
.col {
border-left: 1px solid white;
padding: 0 0 0 1rem;
margin: 0 0 0 1rem;
font-size: .6rem;
}
a:hover .col { border-color: red; }
<a class="navbar-brand navbar-brand-fix" href="<?php echo site_url('/') ?>">
<span class="name">Elliott Davidson</span>
<span class="col">
Growth Hacker<br>
Entrepreneur
</span>
</a>
Hopefully this may get you started :-)
.logo {
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
}
.logo > * {
flex: 0 0 auto;
}
.title {
display: flex;
flex-direction: column;
flex-wrap: nowrap;
align-items: center;
justify-content: center;
}
.title > * {
flex: 0 0 auto;
}
<div class="logo">
<div class="name">
Elliott Davidson
</div>
<div class="title">
<div class="funText">
Growth Hacker
</div>
<div class="position">
Entrepreneur
</div>
</div>
</div>