Placing a vertical divider between text - html

I need a vertical divider and the text to line up exactly like this on the top right hand corner of my screen.
I am having some trouble even getting the divider to show and the text to pull right
<div class="row">
<div class="float-right">
<span>Profile & Settings</span>
</div>
<div class="float-right sep">
<div class="septText"></div>
</div>
<div class="float-right">
<span>Logout</span>
</div>
</div>
Css
.sep {
display: flex;
flex-direction: column;
justify-content: center;
}
.sepText {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex: 1;
}
.sepText::before,
.sepText::after {
content: '';
flex: 1;
width: 1px;
background: currentColor;
/* matches font color */
margin: .25em;
}

I can see that bootstrap 4 tag is added to your question. If you are using bootstrap 4, there is a in-built flex utility https://getbootstrap.com/docs/4.0/utilities/flex/
<div class="d-flex flex-row justify-content-end">
<div class="">
<span>Profile & Settings</span>
</div>
<div class="mx-2">|</div>
<div class="">
<span>Logout</span>
</div>
</div>
JS Fiddle: https://jsfiddle.net/8p27xwcs/

use "container" instead of "row", or set display:inline or block on the row div.
<div class="row" style="display:inline;" >
<div class="float-right">
<span>Profile & Settings</span>
</div>
<div class="float-right sep">
<div class="septText"></div>
</div>
<div class="float-right">
<span>Logout</span>
</div>
</div>
or
<div class="container">
<div class="float-right">
<span>Profile & Settings</span>
</div>
<div class="float-right sep">
<div class="septText"></div>
</div>
<div class="float-right">
<span>Logout</span>
</div>

Related

how to display cards on the same line using display flex?

I need to display cards on the same line and use flex-wrap: wrap to wrap. But it's not working, what's wrong with my code?
Code
return(
<div className='container-poster'>
<div className='poster'>
<div className='poster-img'>
<img src={poster} />
<i>
{isFavorite ?
<FaHeart className='heart-icon' style={{ color: 'red' }} /> : <FaHeart className='heart-icon' style={{ color: '#BABABA' }} />
}
</i>
</div>
<div className='poster-title-vote'>
<h4 className='title-movie'>
{title}
</h4>
<div className='box-note'>
<span className='rating'>{rating}</span>
<i className='icon-vote-like'>
<img src={IconLike} alt="icon like"></img>
</i>
</div>
</div>
<p className='overview'>
{overview}
</p>
</div>
</div>
)
Reality
I want it to be a maximum of 4 cards in the same row and then break it when there's no space
SandBox
https://codesandbox.io/s/jolly-waterfall-10s5gx?file=/src/Poster.js
You'll want to add display: flex; on your parent .container-poster. This will make all elements nested in each flex-item .poster row item. You can then use display: flex; with flex-direction: column on your .poster to get the title underneath.
See below:
.container-poster {
display: flex;
justify-content: space-between;
}
.poster {
text-align: center;
display: flex;
flex-direction: column;
width: calc(100%/4.1); /* .1 for spacing */
}
img {
max-width: 100%;
}
<div class='container-poster'>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
<div class='poster'>
<div class='poster-img'>
<img src="https://dummyimage.com/300/000/fff" />
</div>
<div class='poster-title-vote'>
<h4 class='title-movie'>Title
</h4>
</div>
<div class='box-note'>
<span class='rating'></span>
</div>
</div>
</div>

How to remove Space CSS overflow-x in mobile design

I try to make a slide card for mobile design by implement overflow-x.
However, this leaves some space on the right side of the screen which is really annoying. How can I fix this?
I have used the following style to get rid of the extra space on the right side of the screen:
Here is my html code
<div class="pet-group">
<!-- Pet List Widget -->
<div class="row justify-content-md-center text-center flex-nowrap2">
<div class="w-25 p-3" data-step="2" data-intro="You also can add your other pet!" data-position='right'
data-scrollTo='tooltip'>
<div class="card widget-profile pet-widget-profile ">
<div class="card-body card-mobile">
<div class="propet-widget-content ">
<div class="pet-info-widget ">
<a href="add-pets.html" class="booking-doc-img ">
<img src="assets/img/addpet.png " alt="users Image ">
</a>
<div class="profile-det-info ">
<h3><a href="add-pets.html " class="stretched-link ">
Add Pet </a> </h3>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="w-25 p-3" data-step="1"
data-intro="Hey, its Ricky! You can click here to view or update your pet story." data-position='left'>
<div class="card widget-profile pet-widget-profile ">
<div class="card-body card-mobile">
<div class="propet-widget-content ">
<a href="profile-pet.html" class="booking-doc-img ">
<div class="pet-info-widget ">
<img src="assets/img/pets/cat1.png " alt="users Image ">
</a>
<div class="profile-det-info ">
<h3><a href="profile-pet.html" class="stretched-link ">
Ricky </a><span class="badge badge-pill bg-success-light gender">Male</span></h3>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="w-25 p-3">
<div class="card widget-profile pet-widget-profile ">
<div class="card-body card-mobile">
<div class="propet-widget-content">
<a href="profile-pet.html" class="booking-doc-img ">
<div class="pet-info-widget ">
<img src="assets/img/pets/cat2.png " alt="users Image ">
</a>
<div class="profile-det-info ">
<h3><a href="profile-pet.html" class="stretched-link ">
Bucky </a><span class="badge badge-pill bg-warning-light gender">Female</span></h3>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here is my css code
.pet-group {
margin-top: -70px;
display: flex !important;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
scroll-direction: horizontal;
-webkit-overflow-scrolling: touch;
&::-webkit-scrollbar {
display: none;
}
}
.flex-nowrap2 {
padding: 15px;
list-style: none;
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: nowrap;
flex-wrap: nowrap;
}
Try
.flex-nowrap2 {
padding-right: 0px;
}
inside Mobile Size Media Query.
remove padding
.flex-nowrap2 {
padding: 0;
}
If you want padding to text just add padding to title tags only.

Contact section wont centralize

Updated Position I have a problem I can't seem to centralize my contact information. Below is the code I have that pushes all the small logos with the text to the side of the webpage.
However, my final goal is to have them placed in one line. Any help is welcome!
.media {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: start;
-ms-flex-align: start;
align-items: flex-start
}
.media-body {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1
}
<section class="contact-section">
<div class="col-lg-3 offset-lg-1">
<div class="media contact-info">
<span class="contact-info__icon"><i class="ti-home"></i></span>
<div class="media-body">
<h3>Buttonwood, California.</h3>
<p>Rosewoodly, PA 750918</p>
</div>
</div>
<div class="media contact-info">
<span class="contact-info__icon"><i class="ti-tablet"></i></span>
<div class="media-body">
<h3>+2 257 995 2885</h3>
<p>Mon to Fri 7am to 6pm</p>
</div>
</div>
<div class="media contact-info">
<span class="contact-info__icon"><i class="ti-email"></i></span>
<div class="media-body">
<h3>support#testemail.com</h3>
<p>Send us a message anytime!</p>
</div>
</div>
</div>
Here you are using flexbox. If you want all children to be in one line.
Just wrap around one more div to all and give it display:flex
<section class="contact-section">
<div class="col-lg-3 offset-lg-1">
<div class="media-wrapper">
<div class="media contact-info"></div>
<div class="media contact-info"></div>
<div class="media contact-info"></div>
</div>
</div>
</section>
and then add following css
.media-wrapper {
display:flex;
}
https://codepen.io/ksilentstorm/pen/eYmeXvr
For knowledge purpose
Just adjust child elements by putting following lines in parent css that is .media-wrapper.
For horizontal alignment - justify-content: center/flex-start/flex-end;
For vertical alignment align-items: center/flex-start/flex-end;
For direction flex-direction: row or flex-direction: column
Note: When direction changes justify-content and align-items both exchange its nature.
For more info. you can visit.
https://www.w3schools.com/css/css3_flexbox.asp
Try this
.media {
/* display: -webkit-box; */
display: -ms-flexbox;
display: flex;
-webkit-box-align: start;
-ms-flex-align: start;
align-items: flex-start;
float: left;
text-align: center;
margin: 0 17px;
}
.media-body {
width: 100%;
}
<section class="contact-section">
<div class="col-lg-3 offset-lg-1">
<div class="media contact-info">
<span class="contact-info__icon"><i class="ti-home"></i></span>
<div class="media-body">
<h3>Buttonwood, California.</h3>
<p>Rosewoodly, PA 750918</p>
</div>
</div>
<div class="media contact-info">
<span class="contact-info__icon"><i class="ti-tablet"></i></span>
<div class="media-body">
<h3>+2 257 995 2885</h3>
<p>Mon to Fri 7am to 6pm</p>
</div>
</div>
<div class="media contact-info">
<span class="contact-info__icon"><i class="ti-email"></i></span>
<div class="media-body">
<h3>support#testemail.com</h3>
<p>Send us a message anytime!</p>
</div>
</div>
</div>
Restructured your HTML code and styled using flex.Hope this helps you.
<section>
<div class="contact-section">
<div class="address">
<span class="contact-info__icon"><i class="ti-home"></i></span>
<div class="media-body">
<h3>Buttonwood, California.</h3>
<p>Rosewoodly, PA 750918</p>
</div>
</div>
<div class="contactInfo">
<span class="contact-info__icon"><i class="ti-tablet"></i></span>
<div class="media-body">
<h3>+2 257 995 2885</h3>
<p>Mon to Fri 7am to 6pm</p>
</div>
</div>
<div class="email">
<span class="contact-info__icon"><i class="ti-email"></i></span>
<div class="media-body">
<h3>support#testemail.com</h3>
<p>Send us a message anytime!</p>
</div>
</div>
</div>
Css change
.contact-section{ display:flex;}

Break line using Flex keeping elements centered

This is another CSS Flex question, I'm sorry but I've been struggling a lot using Flex, I'm trying to make a kind of slider, in which it will have a left and right arrow and elements in between, like so:
The problem I'm facing is that in certain number of elements I need to break a line, keeping the alignment center both vertically and horizontally, like this: (paint pro editing)
I can't find a way to do this, I'm lost.
This is my actual code for the first image:
HMTL:
<div class="main allin">
<div class="left-arrow">
<i class="material-icons">keyboard_arrow_left</i>
</div>
<div class="flex-con ">
<div class="item-1">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-2">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-3">
<img src="https://via.placeholder.com/250" />
</div>
</div>
<div class="right-arrow">
<i class="material-icons">keyboard_arrow_right</i>
</div>
</div>
<div class="main break">
<div class="left-arrow">
<i class="material-icons">keyboard_arrow_left</i>
</div>
CSS:
.main{
display:flex;
justify-content: center;
align-items: center;
}
.flex-con{
display:flex;
align-items: center;
}
.flex-con div{
padding:20px;
}
And this is a CodePen
How can I achieve this? thanks.
Put all your item-x elements within the same flex-con wrapper.
Then, simply add the following properties:
flex-wrap: wrap; // to wrap its children into multiple lines
justify-content: center; // to center horizontally
.main {
display: flex;
justify-content: center;
align-items: center;
}
.flex-con {
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: center;
}
.flex-con div {
padding: 20px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/material-design-icons/3.0.1/iconfont/material-icons.min.css" />
<div class="main break">
<div class="left-arrow">
<i class="material-icons">keyboard_arrow_left</i>
</div>
<div class="flex-con ">
<div class="item-1">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-2">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-3">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-4">
<img src="https://via.placeholder.com/250" />
</div>
<div class="item-5">
<img src="https://via.placeholder.com/250" />
</div>
</div>
<div class="right-arrow">
<i class="material-icons">keyboard_arrow_right</i>
</div>
</div>
Click Full page for better demonstration.

How to draw equal horizontal lines between one button to another in angular 4

Here I am trying to draw a horizontal line between the buttons. I have tried in many ways but I can't get it. I think I need to do some magics in CSS but I am new to HTML and CSS That's why I can't find the way to make it work.
I want:
I got this:
.divided {
display: flex;
align-items: center;
}
.divider {
flex-grow: 1;
border-bottom: 1px solid black;
margin: 5px
}
<div class="col-sm-9" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3">
<button mat-mini-fab>1</button>
<span style="padding-left:15px">Login</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>2</button>
<span style="padding-left:15px">Address</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>3</button>
<span style="padding-left:15px">Mycart</span>
</div>
<span class="divider"></span>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:15px">Payment</span>
</div>
</div>
</div>
</div>
</div>
Can anyone help me to solve this ?
Update:
Use pseudo :after to <div class="col-sm-3 divder">
Instead using <span class="divider"></span> (-- remove it)
.divder:after{
content: '';
width: 71px;
height: 2px;
top: 15px;
background: black;
position: absolute;
right: -12px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<div class="container">
<div class="row">
<div class="col-sm-9" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3 divder">
<button mat-mini-fab>1</button>
<span style="padding-left:15px">Login</span>
</div>
<div class="col-sm-3 divder">
<button mat-mini-fab>2</button>
<span style="padding-left:15px">Address</span>
</div>
<div class="col-sm-3 divder">
<button mat-mini-fab>3</button>
<span style="padding-left:15px">Mycart</span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:15px">Payment</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I think you're trying to do the same as you would do when using a stepper
https://material.angular.io/components/stepper/overview
Using import {MatStepperModule} from '#angular/material/stepper';
and the correct elements will do the trick
You can use :after psuedo class
.divider:after {
height:1px;
width:40px;
content:'';
background: red;
position:absolute;
right:0px;
top:15px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
<div class="col-sm-12" style="padding-left:0px;padding-right:0px">
<div class="col-sm-12 row">
<div class="container" style="padding-left:0px;padding-right:0px">
<div class="row divided">
<div class="col-sm-3">
<button mat-mini-fab>1</button>
<span style="padding-left:0px">Login</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>2</button>
<span style="padding-left:0px">Address</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>3</button>
<span style="padding-left:0px">Mycart</span>
<span class="divider"></span>
</div>
<div class="col-sm-3">
<button mat-mini-fab>4</button>
<span style="padding-left:0px">Payment</span>
</div>
</div>
</div>
</div>
</div>
Following code adds equally sized lines between menu items as long there is enough space.
/* all direct children of menu and item are laid out in a single row as long as there is enough space */
.menu,
.item {
display: flex;
flex-flow: row wrap;
}
/* all menu items can grow except the last one */
.item:not(:last-child) {
flex-grow: 1;
}
/* a horizontal line is appended to all items if space is available (except the last item) */
.item:not(:last-child):after {
content: '';
border-bottom: 1px solid #000;
height: 50%; /* centers line vertically */
flex-grow: 1;
margin-right: 10px;
}
/* not relevant for menu (typography and resets) */
button,
span {
font-family: Times;
font-size: 16px;
padding: 0;
border: 0;
margin-right: 10px;
}
/* not relevant for menu (rounded buttons) */
button {
background-color: #ddd;
border-radius: 50%;
height: 20px;
width: 20px;
}
<div class="menu">
<div class="item">
<button>1</button>
<span>Login</span>
</div>
<div class="item">
<button>2</button>
<span>Address</span>
</div>
<div class="item">
<button>3</button>
<span>Mycart</span>
</div>
<div class="item">
<button>4</button>
<span>Payment</span>
</div>
</div>
A