I'm trying to create two rows of buttons, 3 on the top and 4 on the bottom to sit centred on the page
[Image showing what I am trying to do][1] [1]: https://i.stack.imgur.com/HgVLS.jpg
I've managed to get the two rows, however when i try and centre them on the page by adding:
display: flex; justify-content: center;
I loose the gap around each of the buttons - I can't work out where to add the padding to give a consistent space between each button!
I was also hoping for the buttons to be mobile responsive and wrap on smaller screens. However I can't seem to figure this out either!
Would really appreciate any help.
.jd-btn {
padding: 10px 35px;
border: solid 1px red;
display: inline-block;
text-align: center;
font-size: 1.6rem;
}
.jd-btn:hover,
.jd-btn:focus {
cursor: pointer;
background-color: red;
color: #fff;
}
<div style="display: flex; justify-content: center;">
<a class="jd-btn">Button 1</a>
<a class="jd-btn">Product info 2</a>
<a class="jd-btn">Button 3</a><br />
</div>
<div style="display: flex; justify-content: center;">
<a class="jd-btn">Account info 4</a>
<a class="jd-btn">Product info 5</a>
<a class="jd-btn">Help 6</a>
<a class="jd-btn">Button 7</a>
</div>
</div>
Related
In Elementor I am using the Social Icons component (Multi-column layout) nesting it inside a Section's Column (Flexbox layout).
However, Safari is not able to determine its position accurately because the CSS property --grid-column-gap is not implemented there properly when the element is nested inside Flexbox layout.
https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap#browser_compatibility
Safari does not recognize the gaps when centering the grid, so the layout is off by 4x14px.
The below code is from Elementor (without modification), how can I solve this issue with Safari?
HTML:
<div class="elementor-widget-wrap ui-sortable">
<div data-id="fe6279a" data-element_type="widget"
class="elementor-element elementor-element-edit-mode elementor-element-fe6279a elementor-element--toggle-edit-tools elementor-widget elementor-widget-social-icons elementor-shape-circle elementor-grid-0 elementor-element-editable"
data-model-cid="c1624" id="" data-widget_type="social-icons.default">
<div class="elementor-widget-container">
<div class="elementor-social-icons-wrapper elementor-grid">
<div class="elementor-grid-item">
<a class="elementor-icon elementor-social-icon elementor-social-icon-linkedin-in elementor-animation-push elementor-repeater-item-cd42a4c"
href="https://www.linkedin.com" target="_blank">
<span class="elementor-screen-only">Linkedin-in</span>
<i class="fab fa-linkedin-in"></i> </a>
</div>
<div class="elementor-grid-item">
<a class="elementor-icon elementor-social-icon elementor-social-icon-xing elementor-animation-push elementor-repeater-item-38c83d4"
href="https://www.xing.com" target="_blank">
<span class="elementor-screen-only">Xing</span>
<i class="fab fa-xing"></i> </a>
</div>
<div class="elementor-grid-item">
<a class="elementor-icon elementor-social-icon elementor-social-icon-twitter elementor-animation-push elementor-repeater-item-002da7e"
href="https://www.twitter.com" target="_blank">
<span class="elementor-screen-only">Twitter</span>
<i class="fab fa-twitter"></i> </a>
</div>
...
</div>
</div>
</div>
</div>
CSS:
/* Parent element */
.elementor-2503 .elementor-element.elementor-element-08404ae.elementor-column.elementor-element[data-element_type="column"] > .elementor-column-wrap.elementor-element-populated > .elementor-widget-wrap {
align-content: center;
align-items: center;
}
.elementor-2503 .elementor-element.elementor-element-08404ae.elementor-column > .elementor-column-wrap > .elementor-widget-wrap {
justify-content: center;
}
.elementor:not(.elementor-bc-flex-widget) .elementor-widget-wrap {
display: -webkit-box;
display: -ms-flexbox;
display: flex; /* Parent element uses Flex layout */
}
.elementor-widget-wrap {
position: relative;
width: 100%;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
-ms-flex-line-pack: start;
align-content: flex-start;
}
/* Child element*/
.elementor-2503 .elementor-element.elementor-element-fe6279a {
--grid-template-columns: repeat(0, auto);
--icon-size: 18px;
--grid-column-gap: 14px; /* Does not work in Safari */
}
.elementor-widget-wrap>.elementor-element {
width: 100%;
}
.elementor-widget {
position: relative;
}
My solution consists of disabling grid-column-gap in Elementor
and creating this custom site-wide code that uses border-right instead.
.elementor-social-icons-wrapper .elementor-grid-item {
border-right: 14px solid transparent;
}
.elementor-social-icons-wrapper .elementor-grid-item:last-child {
border-right: 0px solid transparent;
}
The problem is, I'm trying to test my template for all the browsers, it looks fine in Chrome (I use it primarily) but it looks off in Firefox and Explorer.
I tried to use prefixes, I used auto prefix in brackets to make sure everything is as it should. in Firefox, the background is not showing, and the search bar doesn't have the correct padding that I gave it. Same thing with explorer but the search bar is fine but the background not so much.
.header {
background-image: url(images/headerimg.webp);
background-size: cover;
background-position: center;
height: 300px;
padding: 0;
margin: 0;
text-align: center;
}
.searchContainer {
float: left;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: start;
-ms-flex-pack: start;
justify-content: flex-start;
}
.search {
padding: 7px 10px !important;
border-radius: 0 4px 4px 0;
font-size: 17px;
border: 2px solid #363a5e;
border-left: none;
width: 360px;
color: #666a8c;
margin: 1px 0 0 -3px;
background-color: #363a5e;
-webkit-transition: .2s;
transition: .2s;
}
<header class="header jumbotron" role="heading" aria-level="1">
<div class="filter">
<div class="container">
<div class="mobileOpenContainer">
<span onclick="openNav()" class="showNavSearch"><i class="fas fa-bars"></i></span>
<span onclick="openSearch()" class="showNavSearch" id="search"><i class="fas fa-search"></i></span>
</div>
<div class="logoNavContainer" role="img">
<img class="logo" src="images/Logo.svg" alt="logo">
<nav>
<ul class="navbar" role="navigation">
<a href="#">
<li class="nav">خانه</li>
</a>
<a href="#">
<li class="nav">تبلیغات</li>
</a>
<a href="#">
<li class="nav">تماس با ما</li>
</a>
<a href="#">
<li class="nav">خرید قالب</li>
</a>
</ul>
</nav>
</div>
<div class="reqSearchContainer">
<button class="request" role="button"><i class="fas fa-film"></i>درخواست انتشار</button>
<button class="request" role="button"><i class="fas fa-heart"></i>حمایت از ما</button>
<div class="searchContainer">
<label>
<input class="search" placeholder="جستوجو..." aria-label="Searchbar">
<span class="searchBtn" aria-label="Search button"><i class="fas fa-search"></i></span>
</label>
</div>
</div>
</header>
This is how it looks like in Chrome (how it should):
This is Firefox:
IE is the same as Firefox, but the search bar is fine.
Okay I found a way to do it, but it may not be the best for some who have the same problem as I had:
First of all, to be able to see the background, I had to update to Firefox 65+ because .webp is supported from that version, it seems (for IE, it doesn't support it at all, which is a shame, so I just changed it to jpg)
For the searchbar however, I didn't find any good way to fix the padding, so I just used height in CSS to give it fixed height and that also fixed that problem, but may not be the best option for some.
As you will tell from this question I'm still new with Flexbox as well as with SASS. I have an MVC app where I'm trying to align the header login information depending on if they are authenticated or not.
What I'm trying to accomplish is to have my header with a logo to the left and some login/register buttons flush to the bottom in a single row if you are not authenticated or their username and logoff/account info stacked on top of each other if they are authenticated.
I'm trying to use flexbox to accomplish these. The idea is I would have an overall parent container "header_account-info", the logo in the "header__logo" child container, and other login parts in either "header_account-user" or "header-account-login". For testing I'm using the "header-account-login" container.
With the code below I can not get the "header-account-login" container to have a background color (using for testing) nor can I get it to align to the bottom.
I put this in Code Pen and see the same results.
https://codepen.io/anon/pen/WgGxQL
Why would I not see a background color in my "header-account-login" container and I thought I had the correct setting to make the buttons go to the end (bottom) of the container?
HTML
<div class="header">
<div class="header__logo">
<img src="~/images/logo.png" class="header-logo" />
</div>
<div class="header_account-info">
<div class="header-account-login">
<a href="#Url.Action("Register", "Account")" id="registerLink" class="btn btn-outline-secondary">
<i class="far fa-user-plus"></i> Register
</a>
<a href="#Url.Action("Login", "Account")" id="loginLink" class="btn btn-outline-secondary">
<i class="fas fa-sign-in-alt"></i> Log In
</a>
</div>
</div>
</div>
SASS
.header {
display: flex;
padding: 3px;
&__logo {
/*flex: 1;*/
margin-right: auto;
background-color: aqua;
height: 100px; /*TESTING*/
}
&__account-info {
display: flex;
background-color: aquamarine;
}
&__account-user {
background-color: blanchedalmond;
}
&__acount-login {
align-items: flex-end;
background-color: aquamarine;
}
}
Why would I not see a background color in my "header-account-login" container and I thought I had the correct setting to make the buttons go to the end (bottom) of the container?
Because you have typos in your HTML/CSS - in some cases you are using a single underscore and in others two. Also "account" is incorrectly spelled in some places.
As for the lauot, I think this will suffice:
.header {
display: flex;
padding: 3px;
justify-content: space-between;
}
.header__logo {
/*flex: 1;*/
margin-right: auto;
background-color: aqua;
height: 100px;
}
.header__account-info {
display: flex;
align-items: flex-end;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="header">
<div class="header__logo">
<img src="http://www.fillmurray.com/g/140/100" class="header-logo" />
</div>
<div class="header__account-info">
<div class="header__account-login">
<a href="#Url.Action(" Register ", "Account ")" id="registerLink" class="btn btn-outline-secondary">
<i class="far fa-user-plus"></i> Register
</a>
<a href="#Url.Action(" Login ", "Account ")" id="loginLink" class="btn btn-outline-secondary">
<i class="fas fa-sign-in-alt"></i> Log In
</a>
</div>
</div>
</div>
Here is one way to make it work:
.header-account-info {
position: relative;
}
.header-account-login {
background-color: red;
position: absolute;
bottom: 0px;
right: 0px;
width: 158px;
}
The way you are trying to call your class (i.e. "&__acount-login") is wrong - just give yourself the full class name like my example.
At this site, there is a div.social below the Online Bookings at top right of the screen.
http://imgur.com/a/QhlIL
Note: I've not been able to upload images to SO for months - always says the image is too large (> 2MB) when it is 140 KB.
For some reason .social is not displaying, nor its sub-elements:
<div class="social">
<a title="Trip Advisor" href="#" target="_blank">
<div class="tripAdvisor"></div>
</a>
<a title="Facebook" href="#" target="_blank">
<div class="facebook"></div>
</a>
<a title="Instagram" target="_blank" href="#">
<div class="instagram"></div>
</a>
<a title="YouTube" target="_blank" href="#">
<div class="youtube"></div>
</a>
</div>
<style>
.headRight .tripAdvisor {
background: url(../images/social/tripadvisor.png) no-repeat;
width: 28px;
height: 22px;
}
</style>
.social is set to display: block; and there is enough room to fit the icons in.
Help appreciated.
Just checked the bug on your website.
You must apply the style to the child divs of .social
.social div {
display: inline-block;
margin-right: 15px;
display: inline; // remove this line
zoom: 1;
}
remove the
"display: inline"
Just keep
.social div {
display: inline-block;
margin-right: 15px;
zoom: 1;
}
from that class. Will work perfectly.
I need to make my app title centered in the app Semantic menu.
Below is my current code :
HTML:
<div class="ui red inverted borderless top attached menu">
<div class="ui red dropdown icon launch button">
<i class="sidebar icon"></i>
</div>
<a class="item mytitle ">My App Title</a>
<div class="ui right aligned category search item">
User Name
</div>
</div>
CSS :
.mytitle {
display: table-cell;
text-align: center;
vertical-align: middle;
height: 35px;
display: table-cell;
color: #FFFFFF;
text-decoration: none;
}
I tried to add the width="90%" in the CSS, but although it is able to make it centered, it pushed the Username, which I want to avoid.
Is there another way to make it centered?
Here is my current JSFiddle
Like This https://jsfiddle.net/DIRTY_SMITH/85fenw7t/1/
.mytitle {
height: 35px;
color: #FFFFFF;
text-decoration: none;
margin-left: calc(50% - 90px);
}