How to format this list in ionic? - html

I have the following list that shows: one icon, a user pic, name, and 2 icons on the left.
I cannot align then properly in ionic, even when I add styling I cannot fix them.
Can you please give me a hint how to make this item be inline in the order I mentioned above?
<div class="list">
<a class="item item-icon-left item-icon-right" href="#" style="margin-top:40px;">
<i class="icon ion-person"></i>
<img class="circular-image" src="/Content/img/bill.jpg" />
<h2 style="display:inline; padding-left:10px;">F.joe</h2>
<i class="icon ion-chatbubble-working"></i>
</a>
<a class="item item-icon-left item-icon-right" href="#">
<i class="icon ion-person"></i>
<img class="circular-image" src="/Content/img/bill.jpg" />
<h2 style="display:inline; padding-left:10px;">F.joe</h2>
<i class="icon ion-chatbubble-working"></i>
</a>
</div>

I would suggest using Ionic's grid CSS component:
http://ionicframework.com/docs/components/#grid
Try something like this:
<ion-list>
<ion-item>
<div class="row">
<div class="col">
<i class="icon ion-person"></i>
</div>
<div class="col">
<img class="circular-image" src="/Content/img/bill.jpg" />
</div>
<div class="col">
<h2>F.joe</h2>
</div>
<div class="col">
<i class="icon ion-chatbubble-working"></i>
</div>
</div>
</ion-item>
</ion-list>
You can mess with the row and col classes to give your list your desired look and feel. For example "col col-25" will make that column take up 25% of the screen.

Another option is to use the flexbox to align the items inside the item, defining three sections .item-content-left, item-content-center (with flex-grow to expand) and .item-content-right
but for something simpler I would take Jake Stewart approach.
<div class="list">
<a class="item" href="#" >
<div class='item-content'>
<div class='item-content-left'>
<i class="icon ion-person"></i>
</div>
<div class='item-content-center'>
<img class="circular-image" src="/Content/img/bill.jpg" />
<h2 >F.joe</h2>
</div>
<div class='item-content-right'>
<i class="icon ion-chatbubble-working"></i>
<i class="icon ion-chatbubble-working"></i>
</div>
</div>
</a>
</div>
CSS
.item-content{
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
align-items: flex-start;
-webkit-align-items: flex-start;
}
.item-content-left{
}
.item-content-right{
}
.item-content-center{
flex-grow: 1;
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
align-items: flex-start;
-webkit-align-items: flex-start;
}
http://jsfiddle.net/6Lvu98pb/3/

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>

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;}

Placing a vertical divider between text

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>

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.

Bootstrap put container in container fluid

I want to make two different column background, for that I set container-fluid, and make two columns, and make another row.. but It don't want to work.
I need like this (PHOTO)
Here is my code
<section id="mid">
<div class="container-fluid mid">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-6 left">
<div class="container">
<h2>Inovative macaroons</h2>
<div class="media">
<div class="media-left">
<a href="#">
<span class="fa-stack fa-2x media-object">
<i class="fa fa-circle fa-stack-2x bg"></i>
<i class="fa fa-tag fa-stack-1x fa-inverse"></i>
</span>
</a>
</div>
<div class="media-body">
<h3 class="media-heading">Best Prices</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce malesuada et.</p>
</div>
</div>
</div>
</div>
<div class="col-md-6 right">
<h2> Specials</h2>
</div>
</div>
</div>
</div>
</div>
</section>
In "left" css I made white BG, and In right I made pink.
Use flex css to achieve this. If i am understanding you right, you want both columns to have same height as the one column with the largest height due to text.
Add the following css in your code
.flex-row {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}
.flex-row > [class*='col-'] {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
Then apply the flex-row to the row containing the left and right colomns
<div class="row flex-row">
<div class="col-md-6 left">
<div class="container">
Hope this helps.