I've been trying to imitate what I consider is a great design for top navigation. The top navigation is from this website here: Giphy
For my layout I've been using BassCSS latest version which is the Basscss v8.0.1. Here's what I have so far:
HTML:
<div class="clearfix xs-hide mx-auto bg-white flex flex-justify md-col-12 lg-col-8 mb1">
<div class="col mx-auto center border-bottom border-red strong-border px3">
Home
</div>
<div class="col mx-auto center border-bottom border-green strong-border px3">
Categories
</div>
<div class="col mx-auto center border-bottom border-purple strong-border px3">
Tags
</div>
<div class="col mx-auto center border-bottom border-aqua strong-border px3">
Information
</div>
<div class="col mx-auto center border-bottom border-yellow strong-border px3">
Search
</div>
</div>
<div class="clearfix xs-hide flex mx-auto md-col-12 lg-col-8 mb1">
<label for="search-input" class="hide">Search</label>
<input
type="search"
id="search-input"
class="flex-auto py1 px1 m0 field not-rounded"
placeholder="Search term">
<button class="border black bg-aqua not-rounded">Go</button>
</div>
The CSS files for BassCSS can be found at the official website (I can't post more than two links). I just extended on little thing:
.strong-border{
border-bottom-width: 5px;
}
And that gives me the desire strong border. You can see my version in codepen. That's what I have already but it isn't as good looking as the original because of that white-space problem (Before the links there's some white-space) and this is caused because the links are centered in their container. Also, I don't want the background color to be black and so I was looking for it to look great on white.
Can you please help me to get it a little bit more like the original?
BTW, here's a codepen link with my version on it so you can go ahead and see/play it. :-)
You could use :first-child and :last-child to specify that you don't want the margin left respectively right on the extremity items.
Something like this:
div.mb1 div:first-child {
margin-left: 0;
}
div.mb1 div:last-child {
margin-right: 0;
}
where div.mb1 is the parent and so the properties are specified on the first and last child div.
Here is the updated codepen.
Hope I got the problem right.
Related
The Problem
There is a space below the img in md screen size, and I try to get rid of it.
I've tried to add pa-0 in class, but still can't figure out how to achieve the result.
Restriction
Since the whole code will be received in frontend Nuxt2 in v-html to represent the description + image. So I couldn't add CSS as well. Only vanilla html+ Some Vuetify syntax.
Update
This is for Nuxt2 with Vuetify, using in v-html.
Update ver.2
Initially there is a css attribute in the section of v-html.
margin-bottom: 12px;
But the answer is a good format to code in vanilla html.
my code
<div class="py-6 pa-0">
<div class="row no-gutters align-center" style="background-color: #f6f6f6">
<div class="col-md-6 col-12 order-md-1 order-2 px-4 mb-1">
<h1 class="display-1 py-8">Main Property</h1>
<div class="align-center d-flex justify-space-between mb-1">
<h5>Water</h5>
<div class="mb-1"><small>And more</small></div>
</div>
</div>
<div class="col-md-6 col-12 order-md-2 order-1">
<img class="mx-auto" src="https://images.unsplash.com/photo-1668277280345-f3949c1b6aa2?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1974&q=80" lazy-src="https://images.unsplash.com/photo-1674707735136-3d3a8720397e?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=688&q=80"
alt="test" />
</div>
</div>
</div>
Hey this sounds like an an issue with line height getting the best of things,
simply set the font-size of the image container to 0 and the bottom space should disappear.
div {
font-size: 0;
}
I have a simple css div with some styling from bootstrap and this is the fiddle
https://jsfiddle.net/w9gyc0t5/
This is the code
<!--
Bootstrap docs: https://getbootstrap.com/docs
-->
<div class="container">
<div class="row">
<div class="col-md-6">
<div>
<h5 class="text-danger"><b>General</b></h5>
<h5 class="text-danger float-right"><b>General</b></h5>
</div>
</div>
</div>
I was expecting the H5 element to align perfectly with the element that has been floated right. I know i could move the element floated right to align with the one on the left, but i want to know what is causing this behavior and are there new css innovations such as flex box that solves this problem.
The simplest solution will be to remove the class float-right from second <h5> and put in on the first <h5> like this:
<div>
<h5 class="text-danger float-right"><b>General</b></h5>
<h5 class="text-danger"><b>General</b></h5>
</div>
Here is the fiddle for it: https://jsfiddle.net/6h20bwqc/3/
N.B. But FlexBox is recommended as it is a modern and clean solution.
Just add class="d-flex justify-content-between align-items-center" to the wrapper div and remove float-right for a flex-box solution:
Here is Fiddle for it: https://jsfiddle.net/6h20bwqc/4/
I want the text to look like this on my image:
which is slightly away from the "Center" point of the image(as i want to avoid the phone in the image), so text-center wouldnt work. I currently set the division of the row to "relative" and the text to "Absolute" in order to even get the text on top of the image. But when i resize the image, it will be displaced.
Code:
<section>
<div class="col-lg-12 text-center"style="margin: 0;padding: 0;position: relative;">
<img class="img-fluid" style="width:100%;" src="img/phone-transparent.png" alt=""></img>
<h2 style="color:red;position: absolute; top: 120px; width: 100%;">This is also</br>available on your mobile.</h2>
</div>
</section>
On original screensize:
On a different screensize:
This can be done using only Bootstrap 4 classes. Read the documentation on using the grid, and the utility classes for positioning and flexbox. You don't need all the inline CSS styles.
<div class="container-fluid">
<section class="row no-gutter align-items-center">
<div class="col-lg-12 text-center p-0 d-flex align-items-center">
<img class="img-fluid position-relative mx-auto" src="//placehold.it/1900x400" alt="">
<h3 class="w-100 position-absolute text-danger my-auto">This is also<br>available on your mobile.</h3>
</div>
</section>
</div>
Demo
Remember that .col-* must be placed in the .row, and the .row
should be inside a container.
You can use the spacing utils and CSS object-fit on the image to get the position and size: Demo 2 (you will need to tweak this as desired).
This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
Closed 5 years ago.
I have a full-page bootstrap layout, and on the first page I need something aligned to middle & bottom.
There is a background image (first div), and a darker layer on it (second div).
<div class="h-100 w-100">
<div class="h-100 w-100 text-center">
<div class="h-100 w-100 d-flex align-items-center">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
<h1 style="color:#000;">something</h1>
<a href="">
www.something.com
</a>
<p class="tto_cl">
<span style="font-size: 1.8rem;">123</span>
</p>
<span style="text-transform:uppercase; color:#000; letter-spacing: 4px; font-family: Arial;">456</span><br>
</div>
</div>
</div>
Jsfiddle:
https://jsfiddle.net/543r2dcs/2/
They are aligned center perfectly, but I need something to bottom.
I want the 456 to the bottom of the div, but this new flexbox system is unusual to me.
Bootstrap has a very handy .align-bottom class. You can read about it here
<span class="align-bottom">bottom</span>
Set the parent element position: relative then set the poisition for the element you want to be down the bottom to position: absolute then set its bottom to 0 bottom: 0 this will position it to the bottom of its parent container this might also break how you are centering the element so you will have to add left: 0 and right: 0
If you want it to be vertically centered, use my-auto margin y auto, which brings it to the center
I am learning how to become Front End Developer at Udacity. There is a project that I need to submit. I ran in couple of issues I couldn't find help with, some of my images and urls within divs don't want to align properly. I tried using this website as a solution https://codemyviews.com/blog/how-to-center-anything-with-css
because it offered most variations on aligning blocks... But none of them worked.
<div class="row">
<div class="col-4"><img src="http://www.panext.com/wordpress/wp-content/uploads/2012/09/question-63916_640-400x200.jpg"></div>
<div class="col-4"><img src="http://www.eu-projekti.info/eu/wp-content/uploads/2014/10/1159613_85120857-400x200.jpg"></div>
<div class="col-4 end"><img src="http://www.digitalzenway.com/wp-content/uploads/plan-to-eat-400x200.gif"></div>
</div>
These are images, I am trying to align first image to the left, 2nd to the center and 3rd to the right. I could align them by using margins and paddings in html, but I want it to work with responsive design.
<div class="row">
<div class="col-4">
https://github.com/udacity/Appify/
</div>
<div class="col-4">
https://github.com/udacity/Sunflower/
</div>
<div class="col-4">
https://github.com/udacity/Bokeh/
</div>
</div>
and these are urls right underneath the pictures, that aren't lining up, no matter what I try.
This is the screenshot of my webpage http://picpaste.com/Portfolio-NOGcuGm8.jpg
P.S. This is my first post at Stack Overflow, TIA!
You can use Bootstrap's text-center and text-right classes to modify inner alignment of columns.
<div class="row">
<div class="col-4"><img src="http://www.panext.com/wordpress/wp-content/uploads/2012/09/question-63916_640-400x200.jpg"></div>
<div class="col-4 text-center"><img src="http://www.eu-projekti.info/eu/wp-content/uploads/2014/10/1159613_85120857-400x200.jpg"></div>
<div class="col-4 text-right end"><img src="http://www.digitalzenway.com/wp-content/uploads/plan-to-eat-400x200.gif"></div>
</div>
If you aren't using Bootstrap, these classes simply apply text-align: center and text-align: right respectively.