Simple arrows beside image Bootstrap - html

I have a very trivial problem. I just needed two simple arrows (left and right) vertically aligned to the middle to the image. Arrows have to be responsive and become smaller with screen size.
My code now is just:
<div class="row">
<div class="offset-md-1 col-md-1">
<i class="fa fa-arrow-left" style="position:relative; top:50%"></i>
</div>
<div class="col-md-8 detail_pic">
<img src="#image" style="width:80%;">
<h2 style="text-align:center;">#Title</h2>
</div>
<div class="col-md-1">
<i class="fa fa-arrow-right" style="position:relative; top:50%"></i></div>
</div>
</div>
This looks like the image below. But it doesn't work well when I size down the screen as the cols get stacked over each other. How do I get the arrows and the image in one col and make them responsive?

For the image size...you can have automatically resizing arrow icons by using viewport units like this img{ width: 2vmin} which listens to the shorter of the width/height dimensions in your viewport, and uses a percentage of this dimension... css tricks link for more info css-tricks.com/fun-viewport-units
For positioning the arrows in the center of the div use
img{
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
a helpful article on flexbox vertical centering phillipwalton.com

Related

Vertically and horizontally align content whilst still being responsive

I currently have a simple one page website which displays a logo, 4 short lines of text and 2 buttons which are side by side. I'm using Bootstrap 4.
I have already tried many solutions posted on stack overflow but haven't found a fix.
I am trying to align all of the content horizontally and vertically whilst still being responsive so it is in the middle of the screen on all devices. Would be good to have no scroll however i'm guessing scroll may be required especially on smaller devices such as iPhone SE so that's ok.
The closest I have got is with the code below. This centers correctly however for example, on iPhone SE the logo and buttons are cut off at the top and bottom of the page rather than resizing like responsive should do.
css:
html, body {
height: 100%;
font-family: Arial, sans-serif !important;
overflow:auto;
}
body {
margin: 0;
}
.container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100vh;
}
html:
<div class="container">
<div style="padding:15px;" class="row">
<div class="col text-center">
<center>
<img src="assets/img/logo.png" class="logo" />
<br>
<br>
<p style="margin-top:1rem;" class="big">text</p>
<p>text<br>text<br>text</p><p>text<br>text<br>text</p>
<p class="no-margin">PURCHASE TICKET INSTANTLY ONLINE</p>
<p class="big">OR</p>
<p>RESERVE AND PAY ON ENTRY</p>
<br>
<div class="row">
<div class="col-sm-12 text-center">
<a href="purchase">
<button style="background-color: #db0e0e !important;border:none; line-height: 130%;" class="btn btn-danger btn-md center-block">PURCHASE
<br>TICKET ONLINE</button>
</a>
<a href="purchase"><button style="background-color: #ffffff !important;color: #db0e0e !important;border:none; line-height: 130%;" class="btn btn-danger btn-md center-block">RESERVE
<br>PAY ON ENTRY</button></a>
</div>
</div>
</center>
</div>
</div>
</div>
Flex. See my jsfiddle.
The key is to center both axes with nested flex <div>'s one with a flex-direction of column and one of row, both with justify-content: center. The key "gotcha" with flex is that at least one of the first flex div has to have height: 100%, since flex elements' default height are determined by their contents, not their parent height.

Horizontal alignment to margins while not losing vertical alignment

In HTML, I have two elements, one with text and one containing a couple of buttons.
Instead of touching in the middle, I want them spaced to align to the left and right margins. So I want my text aligned to the left margin, and my buttons aligned to the right margin, without losing their vertical alignment as is.
I also happen to be using Bootstrap 3.
When I use pull-left/pull-right, float:left/float:right, or align="left"/align="right", I get a change in the vertical alignment of these two elements.
Paired down code looks like this essentially:
<div style="width:200px;height:100px">
Delete dashboard?
<button class="btn btn-secondary cancel">
Cancel
</button>
<button class="btn btn-danger">
Delete
</button>
</div>
What is the the most straightforward way to align these items to the left and right margins? I can do it with a table, but is that not the ideal way?
[![A modal example][2]][2]
Without seeing your code, I would use a flex layout. The key in a flex row is to use justify-content: space-between to push 2 children in the row to the far edges. Then align-items on the parent will set the vertical alignment.
.flex {
display: flex;
}
.col {
flex-direction: column;
max-width: 250px;
border: 1px solid black;
}
.bot {
border-top: 1px solid #ccc;
justify-content: space-between;
align-items: center;
}
<div class="flex col">
<div>
<h1>confirm</h1>
</div>
<div class="flex bot">
<p>delete dashboard</p>
<div>
<button>cancel</button>
<button>delete</button>
</div>
</div>
</div>
What about this?
<div class="row">
<div class="col-md-6">Dashboard</div>
<div class="col-md-6 text-right">Cancel Delete</div>
</div>
This will split your area in two columns, where all content of the right column will be aligned right, without affecting the CSS of the elements itself.

Owl Carousel align each item vertically when their height not equal

I'm working on a really simple Html/Bootstrap website.
I'm using owl-carousel library to display and slide multiple paragraphs.
The problem is that when displaying on small devices, these paragraphs will not have the same height, depending on how long they are.
I would like all my owl-item div or paragraph to be aligned vertically within the owl-wrapper div. I tried few display combinations, and also the owl carousel's autoHeight: true option but it does not work as I except.
See the pictures, the little paragraph is displayed on the top of the owl-wrapper div, but I would like it to be centered vertically:
<div class="container">
<div class="caption text-center text-white" data-stellar-ratio="0.7">
<div id="owl-intro-text" class="owl-carousel">
<div class="item">
<h1>Oscar Götting</h1>
</div>
<div class="item">
<h1>Let's build something together</h1>
</div>
</div>
</div>
</div>
Add this to your CSS
.owl-carousel .owl-stage { display: flex; align-items: center; }

CSS: How to align a division with the center of another division?

I am new for web design. I am trying to making a box including an icon and a link. When the screen is laptop, the link should be in the left of the icon and align with its center vertically; when screen is tablet and mobile phone, the icon should be under the bottom of the icon and align with its center horizontally. And the icon is much bigger than the link. Here are the code and images links:
<div class="box">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6">
<span class="info-box-icon"><i class="mega-octicon octicon-server"></i></span>
</div>
<div class="col-xs-12 col-sm-12 col-md-6">
<a class="side-box-link" href="workflow-summary" style="vertical-align:middle;">Work Flow</a>
</div>
</div>
</div>
image links:
bg and md:
http://ww3.sinaimg.cn/bmiddle/77f9deafgw1evmq9c8z5tj206703amx6.jpg
sm and xs:
http://ww3.sinaimg.cn/bmiddle/77f9deafgw1evmq9cxdttj2045041gll.jpg
I've tried many method but still cannot make the link align with the icon's center vertically, and the link is always align in top of the box. The methods I've tried:
Use table, and set the icon and link as two table data: they can align as
what I want, but since they are two column, the link cannot move
down when the screen size change.
Use table, put them in same line: align in the box top.
Use list: align in the box top.
Use margin in CSS: align well in md and bg screen but the icon and
link will have gap in sm and xs as well.
Use "vertical-align:middle" in CSS: just not working
What should I do? Any advice will be appreciate, thank you!
You can use Flexbox, there is a nice guide here A Complete Guide to Flexbox
Also take a look at this this example I made for you, hope it can help you out.
Html code:
<div class="box">
<div class="row">
<div class="icon">
<span class="info-box-icon"><i class="mega-octicon octicon-server"></i></span>
</div>
<div class="link">
<a class="side-box-link" href="workflow-summary" style="vertical-align:middle;">Work Flow</a>
</div>
</div>
And this is the CSS:
.row {
display: flex;
align-items: center;
}
.icon {
width: 200px;
height: 200px;
background-color: salmon ;
}
.link{
padding: 10px;
}
a {
text-decoration: none;
}
#media (max-width: 450px) {
.row {
flex-direction: column;
}
}
I did use fixed sizes with the icon to illustrate, but it'll work with any size.
Take a look at this live example JSFiddle Flex Example

How to center align a div vertically which uses bootstrap?

I have a row with content which should be in the center of the site and a footer at the bottom. The content are divided into two 6 column. i want it to center align vertically according to the screen size. so i tried to give some percentage of top with a position relative but it doesn't work out.
If i give margin-top it is working. In order to make the top we have to give the position, so i have given it relative I don't want position absolute then the footer will come at the top of the site. Other content also will come top i thnik.
How to center align the contents and footer should stay at bottom all time all display size.
HTML
<div class='row'>
<div class='col-md-6 vertical'> content</div>
<div class='col-md-6 vertical'>content right</div>
</div>
<footer>sit at bottom</footer>
CSS
.vertical{
position:relative;
/* margin-top:20%; */ /*works*/
top:20%; /*not works even providing position */
}
JSFIDDLE NOTE: Don't forgot to resize the window then only you can able to see the two column division
<div class='row'>
<div class='col-md-6 '>
<div class="vertical"> content</div>
</div>
<div class='col-md-6 '>
<div class="vertical"> content</div>
</div>
</div>
<footer>sit at bottom</footer>
.vertical{
display: table-cell;
vertical-align:middle;
height: 200px /* Accordingly */
}
Working Fiddle Fiddle.
Apart from using display: table-cell, there is one more way to do it but is not so cross-browser at this moment. Take a look at CSS3 Flexbox.