how to center icon and text in bulma navbar-item - css

I started playing with Bulma and Buefy framework and I'm stuck with this issue.
I'm trying yo replicate the google apps menù, I've create a navbar-item div and put the foloowing code inside:
<div class="columns">
<div class="column">
<a>
<b-icon
icon="cloud-outline">
</b-icon>
<span>function 1</span>
</a>
</div>
<div class="column">
<b-icon
icon="compass">
</b-icon>
Function 2
</div>
<div class="column">
<b-icon
icon="scatter-plot">
</b-icon>
Function 3
</div>
</div>
the output is:
The result that I want to achieve is the following:
How can I center the icon and move the text to a new line?

You could use flexbox to style your links:
.custom-nav a {
display: flex;
flex-flow: column nowrap;
align-items: center;
padding: 1em;
background-color: rgba(0, 0, 0, 0.1);
}
.custom-nav i {
font-size: 3rem;
}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma#0.8.1/css/bulma.min.css" integrity="sha256-1nEaE91OpXJD7M6W5uSiqxhdmrY+lOOTHC1iUxU9Pds=" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/js/all.min.js" integrity="sha256-KzZiKy0DWYsnwMF+X1DvQngQ2/FxF7MF3Ff72XcpuPs=" crossorigin="anonymous"></script>
<div class="columns custom-nav">
<div class="column">
<a href="#">
<i class="fas fa-box-tissue fa-2x"></i>
<span>function 1</span>
</a>
</div>
<div class="column">
<a href="#">
<i class="fas fa-handshake-slash fa-2x"></i>
<span>function 2</span>
</a>
</div>
<div class="column">
<a href="#">
<i class="fas fa-head-side-mask fa-2x"></i>
<span>function 3</span>
</a>
</div>
<div class="column">
<a href="#">
<i class="fas fa-shield-virus fa-2x"></i>
<span>function 3</span>
</a>
</div>
</div>

You can do this with css flex. By using the additional keys:
flex-direction (says what direction the flex should apply)
align-items (aligns the items inside the container)
justify-content (spacing the items inside the container)
.columns {
display: flex;
justify-content: space-evenly;
}
.column {
display: flex;
flex-direction: column;
align-items: center;
}
.columns {
display: flex;
justify-content: space-evenly;
}
.column {
display: flex;
flex-direction: column;
align-items: center;
}
<div class="columns">
<div class="column">
<span>icon</span>
<span>function 1</span>
</div>
<div class="column">
<span>icon</span> Function 2
</div>
<div class="column">
<span>icon</span> Function 3
</div>
</div>

Related

ellipsis not working on bootstrap with flex

I am trying to add ellipsis after 2 lines of icons, the HTML is below. I tried various combinations by going through many pages. Like changing min-width to 0 and others. All the efforts seem to be useless by now. Hence I turned out for some expert eyes on this, please have a look
.ellipsis {
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
overflow: hidden;
text-overflow: ellipsis;
}
.gicon{
background-repeat:no-repeat;
background-position: center center;
background-size: auto 100%;
height: 32px;
width: 32px;
align-self: center;
}
<div class="row facilityRow">
<div class="col d-flex align-content-start flex-wrap ellipsis">
<div class="d-flex flex-column mr-3">
<i class="gicon" path="001-meditation" rel="tooltip" data-toggle="tooltip" data-placement="top" title="Mediation"></i>
<small>Mediation</small>
</div>
<div class="d-flex flex-column mr-3">
<i class="gicon" path="003-yoga" rel="tooltip" data-toggle="tooltip" data-placement="top" title="Yoga"></i>
<small>Yoga</small>
</div>
</div>
</div>
At first, don't use small. Use an element that does not format text, for example, p.
You need to restirct its immediate parent's width. If there is enough space on the x-axis, it does not work.
.ellipsis {
width: 100%;
max-width: 32px;
}
.ellipsis p {
overflow: hidden;
text-overflow: ellipsis;
}
<div class="row facilityRow">
<div class="col d-flex align-content-start flex-wrap">
<div class="d-flex flex-column mr-3">
<i class="gicon" path="001-meditation" rel="tooltip" data-toggle="tooltip" data-placement="top" title="Mediation"></i>
<div class="ellipsis">
<p>Mediation</p>
</div>
</div>
<div class="d-flex mr-3">
<i class="gicon" path="003-yoga" rel="tooltip" data-toggle="tooltip" data-placement="top" title="Yoga"></i>
<div class="ellipsis">
<p>Yoga</p>
</div>
</div>
</div>
</div>

How to align bulma navbar burger to right end of the page?

I am trying to add navbar using bulma css , am new to css couldn't understand why the navburger span is aligning below logo image and not the far end adjacent to the logo. Am using the code with some js toggle active presented in bulma navbar examples here. (https://bulma.io/documentation/components/navbar/)
Any pointers are much appreciated. Thank you.
EDIT
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>NewApp</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.0/css/bulma.min.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.7/js/all.js"></script>
<style>
.navbar-item.is-mega {
position: static;
.is-mega-menu-title {
margin-bottom: 0;
padding: .375rem 1rem;
}
}
#a { grid-area: a; }
#b { grid-area: b; }
#c { grid-area: c; }
#d { grid-area: d; }
#e { grid-area: e; }
#grid {
display: grid;
grid-template-areas:
"a a a a"
"b c d e";
grid-row-gap: 1rem;
}
#media (max-width: 512px) {
#grid {
grid-template-areas:
"a a a"
"b c d"
"e e e";
}
}
.center, .center-column, .top, .right, .bottom, .left {
display: flex;
justify-content: center;
align-items: center;
}
.center-column {
flex-direction: column;
}
.top { align-items: flex-start; }
.right { justify-content: flex-end; }
.bottom { align-items: flex-end; }
.left { justify-content: flex-start; }
.single-spaced, .single-spaced * {
line-height: 1;
}
#media (max-width: 1024px) {
.desktop {
display: none;
}
}
</style>
</head>
<body>
<app-root></app-root>
</body>
</html>
app.component.html
<router-outlet>
<app-header></app-header>
</router-outlet>
header.component.html
<nav class="navbar is-transparent">
<div class="navbar-brand">
<a class="navbar-item" href="https://bulma.io">
<img src="https://bulma.io/images/bulma-logo.png" alt="Bulma: a modern CSS framework based on Flexbox" width="112" height="28">
</a>
<a class="navbar-burger burger" data-target="navbarExampleTransparentExample">
<span></span>
<span></span>
<span></span>
</a>
</div>
<div id="navbarExampleTransparentExample" class="navbar-menu">
<div class="navbar-start">
<!-- FIXME: fix the href link.. -->
<a class="navbar-item" href="https://localhost:4200/">
Home
</a>
<div class="navbar-item has-dropdown is-hoverable">
<a class="navbar-link" href="https://bulma.io/documentation/overview/start/">
Docs
</a>
<div class="navbar-dropdown is-boxed">
<a class="navbar-item" href="https://bulma.io/documentation/overview/start/">
Overview
</a>
<a class="navbar-item" href="https://bulma.io/documentation/overview/modifiers/">
Modifiers
</a>
<a class="navbar-item" href="https://bulma.io/documentation/columns/basics/">
Columns
</a>
<a class="navbar-item" href="https://bulma.io/documentation/layout/container/">
Layout
</a>
<a class="navbar-item" href="https://bulma.io/documentation/form/general/">
Form
</a>
<hr class="navbar-divider">
<a class="navbar-item" href="https://bulma.io/documentation/elements/box/">
Elements
</a>
<a class="navbar-item is-active" href="https://bulma.io/documentation/components/breadcrumb/">
About me
<div class="modal">
<div class="modal-background"></div>
<div class="modal-content">
<!-- Any other Bulma elements you want -->
</div>
<button class="modal-close is-large" aria-label="close"></button>
</div>
</a>
</div>
</div>
</div>
<div class="navbar-end">
<div class="navbar-item">
<div class="field is-grouped">
<p class="control">
<!-- FIXME ; fix the href -->
<a class="bd-tw-button button" data-social-network="Twitter" data-social-action="tweet" data-social-target="https://stakeradix.io" target="_blank" href="https://twitter.com/intent/tweet?text=RadixDPOS: secure radix consensus through stake delegation &hashtags=stakexrdwithmozhi&url=https://stakeradix.io&via=pspk__janasena">
<span class="icon">
<i class="fab fa-twitter"></i>
</span>
<span>
Tweet
</span>
</a>
</p>
<p class="control">
<!-- FIXME: Go to the official radix page -->
<a class="button is-primary" target="_blank" href="https://www.radixdlt.com/">
<span class="icon">
<i class="fas fa-info-circle"></i>
</span>
<span>Explorer</span>
</a>
</p>
</div>
</div>
</div>
</div>
</nav>
Expected:
Actual:

Bootstrap 4 Vertically align footer while respecting columns and rows

I'm trying to find a solution how to vertically align the 2 rows in the footer which are placed with a Bootstrap grid.
I've already tried to make a wrapper for the content and apply the regular flexbox solution:
display: flex; align-items: center. But this moves both rows to be on the same row.
Fiddle here https://codepen.io/pen/WNNPdxv
HTML
<footer class="footer">
<div class="footer-wrapper">
<div class="container">
<div class="row row">
<div class="col-sm-8 footer-credit">
<h6>GetMove</h6>
<p>Copyright &copy 2019 GetMove All Rights Reserved</p>
</div>
<div class="col-sm-2 footer-contact">
<h6>Contact</h6>
hola#getmove.net
</div>
<div class="col-sm-2 footer-social-icons">
<h6>Follow us</h6>
<a class="social-icon" target="_blank" href="https://www.facebook.com/pg/GetMove.Official/"
><i class="fab fa-facebook-square"></i
></a>
<a class="social-icon" target="_blank" href="https://www.instagram.com/getmovemx/"
><i class="fab fa-instagram"></i
></a>
<a class="social-icon" target="_blank" href="https://soundcloud.com/getmove"
><i class="fab fa-soundcloud"></i
></a>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-sm-8 text-center"></div>
<div class="col-sm-4 footer-newsletter">
<h6>Subscribe</h6>
<div class="input-group input-group-sm mb-3">
<input
type="text"
class="form-control shadow-none"
id="subscribe"
placeholder="# Enter your email adress"
aria-label="Sizing example input"
aria-describedby="inputGroup-sizing-sm"
/>
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="button-addon1">
Submit
</button>
</div>
</div>
</div>
</div>
</div>
<div class="container footer-credit">
<div class="row">
<div class="col-sm-8"></div>
<div class="col-sm-4 footer-credit"></div>
</div>
</div>
</div>
</footer>
CSS
.footer {
width: 100%;
height: 24em; /* Set the fixed height of the footer here */
background-color: #f4f2f0;
margin-top: 4em;
}
.footer-social-icons {
list-style-type: none;
}
.footer h6 {
text-transform: uppercase;
font-size: 16px;
}
.footer-credit {
font-size: 11px;
}
.social-icon {
/* display: block; */
margin: 0;
font-size: 16px;
}
.form-control:focus {
border-color: black;
}
The idea of a wrapper to vertically center content is correct, however you already have a wrapper in place => container.
No need to have multiple containers inside a single section (footer). You use rows for this.
So to clean-up your structure a bit, as suggested in the comments, is key to understand what's going on.
container is your wrapper
row row is redundant
empty columns as placeholder are not required with flexbox (bootstrap 4), not sure if that's what's going on... => m-auto, ml-auto, mr-auto
place custom classes inside columns (these blocks might change places someday, especially when designing for a CMS)
keep the structure clean and decorate with utility classes if needed (padding, margin, ...)
HTML Structure
<footer role="contentinfo">
<div class="container">
<div class="row">
<div class="col-sm-7"></div>
<div class="col-sm-3"></div>
<div class="col-sm-2"></div>
</div>
<div class="row">
<div class="col-sm-5 ml-auto"></div>
</div>
<div class="row">
<div class="col-sm-5 ml-auto"></div>
</div>
</div>
</footer>
Solution
Now your height is set on the footer, your container is simply taking the required height inside the space. This means you should now be able to move it vertically with flexbox.
footer[role="contentinfo"] {
display: flex;
flex-flow: column wrap;
justify-content: center; /* content of the footer is the container */
}
DEMO

How to make the header take up the full width in a media query?

I wrote the media queries for smaller screens ,but i can not seem to make them work for ipads. I have a problem with the width of the header and the navbar. They don't seem to take up the full width even though I wrote margin and padding 0 (as an asterisk). The max-width of the html is 1600px. Here is a Print screen.
<header>
<div class="Header-TopContainer">
<div class="Header-MyAccountItem">
<i class="fas fa-user account "></i>
</div>
<div class="Header-MyAccount">
My Account
</div>
<div class="Header-CartItem">
<i class="fas fa-cart-plus cart"></i>
</div>
<div class="Header-Cart">
Cart
</div>
<div class="Header_CheckoutItem">
<i class="fas fa-check-circle check"></i>
</div>
<div class="Header-Checkout">
Checkout
</div>
<div class="Header-VerticalLine"><img src="./Images/first%20hr.png" alt="vertical line"></div>
<div class="Header-Search"><i class="fas fa-search" id="search"></i></div>
</div>
<div class="line mqtablet">
<img src="./Images/long.png" alt="vertical line">
</div>
<div class="Header-LogoContainer mqtablet">
<div class="Header-LogoText">
<h1>Car<span style="color:#ff3448">Store</span></h1>
<p class="Header-LogoSubText">Best Car Seller</p>
</div>
<div class="Header-Phone">
<div class="Header-PhoneIcon">
<i class="fas fa-mobile-alt mobile"></i>
<h2>+123 456 7890</h2>
</div>
<div class="Header-PhoneNumber">
<p class="Header-WorkingHours">mon-fri:8:30am-7:30pm; sat-sun:9:30am-4:30pm</p>
</div>
</div>
<div class="Header-container">
<div class="Header-Wishlist">
<div class="Header-WishlistVLine vline">
<img src="./Images/first%20hr.png" alt="vertical line">
</div>
<div class="Wishlist">
<div class="Header-WishlistIcon">
<i class="fas fa-star wishlisticon"></i>
</div>
<div class="Header-WishlistText">
Wishlist
</div>
</div>
</div>
<div class="Header-Compare">
<div class="Header-WishlistVLine">
<img src="./Images/first%20hr.png" alt="vertical line">
</div>
<div class="Compare">
<div class="Header-CompareIcon">
<i class="fas fa-car compareicon"></i>
</div>
<div class="Header-CompareText">
Compare
</div>
</div>
</div>
<div class="Header-MyCart">
<div class="Header-WishlistVLine">
<img src="./Images/first%20hr.png" alt="vertical line">
</div>
<div class="Mycart">
<div class="Header-MyCartIcon">
<i class="fas fa-cart-plus cart mycarticon"></i>
</div>
<div class="Header-MyCartText'">
My cart
</div>
</div>
</div>
</div>
</div>
</header>
<nav class="toggle-menu">
<label for="toggle">☰</label>
<input type="checkbox" id="toggle"/>
<ul class="MainMenu">
<li>Home</li>
<li>Services</li>
<li>About</li>
<li>Reviews</li>
<li>Locations</li>
<li>Contacts</li>
</ul>
</nav>
#media(min-width:768px) and (max-width:1024px) {
header {
position: relative;
height: 17rem;
text-align: center;
}
.Header-TopContainer,
.Header-Phone {
display: none;
}
.mqtablet {
display: flex;
flex-direction: column;
text-align: center;
}
.Header-LogoText {
margin: 0.5rem;
}
.line {
position: absolute;
top: 9rem;
}
.Header-container {
margin-left: 10%;
}
.vline {
display: none;
}
nav {
text-align: center;
}
ul {
flex-wrap: nowrap;
justify-content: flex-end;
padding-right: 9rem;
}
ul li a {
padding-left: 5rem;
}

Flexbox not wrapping in Firefox and IE11

I have a flexbox grid on my website which is not displaying correctly in IE11 and Firefox.
.section-home {
float: left;
}
/*** Flex Grid ***/
.flex-grid {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
flex-direction: row;
-webkit-flex-direction: row;
justify-content: space-between;
-webkit-justify-content: space-between;
}
.flex-grid .flex-item {
display: flex;
display: -webkit-flex;
margin-top: 2rem;
}
<div class="section-home">
<!-- PRODUCTS -->
<div class="products-home flex-grid">
<div class="flex-item">
<div class="collection-item animated shown">
<div class="collection-wrap">
<div class="collection-image">
<a href="{{ route('cuadrospersonalizados') }}">
<img class="img-responsive" src="{{ FotImg::asset('img/fotolienzos.jpg') }}?dts={DPL_TS}" alt="Cuadros personalizados" title="Cuadros personalizados">
<span class="description">
<p>Lienzo con tus fotos colocado sobre madera de pino</p>
</span>
<div class="caption">
<h2>Fotolienzos</h2>
</div>
</a>
</div>
</div>
</div>
</div>
<div class="flex-item">
<div class="collection-item animated shown">
<div class="collection-wrap">
<div class="collection-image">
<a href="{{ route('fotolienzosconreloj') }}">
<img class="img-responsive" alt="Fotolienzos con Reloj" title="Fotolienzos con Reloj" src="{{ FotImg::asset('img/fotolienzos-con-reloj.jpg') }}?dts={DPL_TS}">
<div class="label-new">
<span class="new">novedad</span>
</div>
<span class="description">
<p>Lienzo personalizado con reloj colocado sobre bastidor de madera</p>
</span>
<div class="caption">
<h2>Fotolienzos con Reloj</h2>
</div>
</a>
</div>
</div>
</div>
</div>
<div class="flex-item">
<div class="collection-item animated shown">
<div class="collection-wrap">
<div class="collection-image">
<a href="{{ route('posterspersonalizados') }}">
<img class="img-responsive" alt="Pósters personalizados" title="Pósters personalizados" src="{{ FotImg::asset('img/posters-personalizados.jpg') }}?dts={DPL_TS}">
<span class="description">
<p>Pósters especialmente pensados para habitaciones juveniles e infantiles</p>
</span>
<div class="caption">
<h2>Pósters personalizados</h2>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- PRODUCTS -->
</div>
The flex grid displays correctly in Chrome but in IE and Firefox the items stay on one line and do not wrap. Why is this?
Your problem is that the container around .flex-grid (.section-home) is set to float: left; and has no width set. This means it will be set to width: auto; which, as it is a floated element, will mean that its content will govern how wide it is. In this case there appears to be a difference in how the browsers choose to calculate the width:
Chrome limits .section-home to the width of its parent
IE lets .section-home grow as much as it needs to accommodate all children of .flex-grid
There are a couple of ways you could tackle this, however, the simplest will be to remove float: left; from .section-home as it appears it is not needed anyway.
.section-home {
/*float: left; Remove this*/
}
/*** Flex Grid ***/
.flex-grid {
display: flex;
display: -webkit-flex;
flex-wrap: wrap;
-webkit-flex-wrap: wrap;
flex-direction: row;
-webkit-flex-direction: row;
justify-content: space-between;
-webkit-justify-content: space-between;
}
.flex-grid .flex-item {
display: flex;
display: -webkit-flex;
margin-top: 2rem;
}
<div class="section-home">
<!-- PRODUCTS -->
<div class="products-home flex-grid">
<div class="flex-item">
<div class="collection-item animated shown">
<div class="collection-wrap">
<div class="collection-image">
<a href="{{ route('cuadrospersonalizados') }}">
<img class="img-responsive" src="{{ FotImg::asset('img/fotolienzos.jpg') }}?dts={DPL_TS}" alt="Cuadros personalizados" title="Cuadros personalizados">
<span class="description">
<p>Lienzo con tus fotos colocado sobre madera de pino</p>
</span>
<div class="caption">
<h2>Fotolienzos</h2>
</div>
</a>
</div>
</div>
</div>
</div>
<div class="flex-item">
<div class="collection-item animated shown">
<div class="collection-wrap">
<div class="collection-image">
<a href="{{ route('fotolienzosconreloj') }}">
<img class="img-responsive" alt="Fotolienzos con Reloj" title="Fotolienzos con Reloj" src="{{ FotImg::asset('img/fotolienzos-con-reloj.jpg') }}?dts={DPL_TS}">
<div class="label-new">
<span class="new">novedad</span>
</div>
<span class="description">
<p>Lienzo personalizado con reloj colocado sobre bastidor de madera</p>
</span>
<div class="caption">
<h2>Fotolienzos con Reloj</h2>
</div>
</a>
</div>
</div>
</div>
</div>
<div class="flex-item">
<div class="collection-item animated shown">
<div class="collection-wrap">
<div class="collection-image">
<a href="{{ route('posterspersonalizados') }}">
<img class="img-responsive" alt="Pósters personalizados" title="Pósters personalizados" src="{{ FotImg::asset('img/posters-personalizados.jpg') }}?dts={DPL_TS}">
<span class="description">
<p>Pósters especialmente pensados para habitaciones juveniles e infantiles</p>
</span>
<div class="caption">
<h2>Pósters personalizados</h2>
</div>
</a>
</div>
</div>
</div>
</div>
</div>
<!-- PRODUCTS -->
</div>

Resources