Positioning Font Awesome icon and a paragraph - html

I wanna position the icon to be on top of the sentence and both centered within bootstrap column. I tried changing the position and display in css for both the paragraph and icon but it doesnt work.
Right now it looks like this
I want it to be like this
Here's the code
#home-info {
width: 500px;
height: 200px;
background-color: rgba(0,0,0,0.7);
top: 550px;
z-index: 1;
position: absolute;
}
.col-md-3 {
height: 100px;
background-color: #1e2c38;
text-align: center;
color: white;
border-bottom: 1px solid white;
border-top: 1px solid white;
}
.col-md-4 {
height: 300px;
text-align: center;
background-color: #1b2328;
}
.col-md-3 p {
position: relative;
width: 300px;
text-align: center;
}
<div class="container-fluid"> <!-- HOME INFO -->
<div class="row">
<div class="col-md-3" id="navy2">
<div class="content-container">
<i class="fa fa-newspaper-o fa-3x" aria-hidden="true"></i>
<p>Learn more about our recent events and news!</p>
</div>
</div>
<div class="col-md-3" id="navy3">
<div class="content-container">
<i class="fa fa-calendar fa-3x" aria-hidden="true"></i>
<p>Stay up to date! Get the school's calendar here!</p>
</div>
</div>
<div class="col-md-3" id="navy2">
<div class="content-container">
<i class="fa fa-facebook-square fa-3x" aria-hidden="true"></i>
<p>Like and connect with us via Facebook!</p>
</div>
</div>
<div class="col-md-3" id="navy3">
<div class="content-container">
<i class="fa fa-youtube fa-3x" aria-hidden="true"></i>
<p>Learn more about us through our videos!</p>
</div>
</div>
</div> <!-- ROW -->
Thanks!

You can center it by making the inner p a display:block element and use margin: 0 auto to center it...
.col-md-3 p {
position: relative;
width: 300px;
display: block;
margin: 0 auto;
}
http://www.codeply.com/go/kFJwok7k0T
However, because you have the 300px set on the .col-md-3 p, the text will get cut-off at smaller widths. It would be better to not set any specific width on the .col-md-3 p so that it's responsive.

You may use <br> tag to separate the icon and text. And since you are using font-awesome icons, you use text-align: center to center both the icon and the text.

Related

How to show hidden div tag when hover on another div tag using css

I have an issue i know it is small but for my necessity i have doubt when i hover on one div i want second div should display and remove cursor again it should hidden how to do this using css
div 2 which will be hidden so when hover on div it should show this div tag and again hover remove it should get hidden using css
<div>
<a href="javascript:void(0)">
<div class="show-all-hover-zone" style="height: 212px;">
<i class="fa fa-chevron-left" style="font-size:25px;color:darkslategrey;position:relative;top:97px;"></i>
</div>
</a>
<div style="background-color:whitesmoke;padding: 3px;height:210px;width:0px;position:absolute;top:164px;display:none;" class="expand-menu1">
</div>
In your case
a:hover ~.expand-menu1{
display: block !important;
}
But don't use inline, please. It can be much more elegant.
For example:
HTML
<a class="hoverOnShow" href="javascript:void(0)">
<div class="show-all-hover-zone">
<i class="fa fa-chevron-left" ></i>
</div>
</a>
<div class="expand-menu1">
</div>
CSS
.show-all-hover-zone{
height: 212px;
}
.fa-chevron-left{
font-size: 25px;
color:darkslategrey;
position:relative;
top: 97px;
}
.expand-menu1{
background-color:whitesmoke;
padding: 3px;
height: 210px;
width: 0px;
position:absolute;
top: 164px;
display:none;
}
.hoverOnShow:hover ~.expand-menu1{
display: block;
}

Placing footer elements

I am currently working on a school assignment where we can only use HTML + CSS (and PHP to include repeated elements, navbar + footer in this case).
For the footer I would like to place 3 elements in the 'Left' - 'Center' - 'Right' part of the footer.
Left: A newsletter bar to enter e-mail with a SIGN UP button
Center: 3 line text - Address, contact, opening hours.
Right: 2 icons - 1 for school and 1 for business'.
This is my code:
HTML:
<footer>
<div class="footer">
<p class="left">Sign up botton here</p>
<p class="right">School - business here</p>
<p class="centered">3 lines with address, contact info, and opening hours.</p>
</div>
CSS:
.left{
text-align:left;
float:left;
}
.right{
float:right;
text-align:right;
}
.centered{
text-align:center;
}
.footer {
position:absolute;
bottom:0;
width:100%;
height:60px;
background:#052D48;
}
.footer p {
color: #fff;
font-size: 8px;
}
How would I go about this? I've been reading and trying stuff for hours, but I just get more confused.
i.imgur.com/6IFJnxF.png Here is a picture of what I have in mind
Hope someone can help me in the right direction, thanks a lot!
Using flexbox and wrapping everything inside a container and a row with a 100% width. Then divide each block by X percentage. I changed the p tags with an unordered list.
.row{
width: 100%;
display: flex;
flex-wrap: wrap;
}
.left{
width: 33%;
height: 40px;
}
.right{
width: 33%
}
.right ul{
list-style: none;
color: white;
}
.middle{
width: 33%
}
.centered{text-align:center;}
.flex{
display: flex;
justify-content: center;
flex-wrap: wrap;
}
.flex-column{
display: flex;
flex-direction: column;
}
.footer {
padding: 20px 10px;
background:#052D48;
}
.footer p{
font-size: 1.3em;
color: #ffffff;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<footer>
<div class="footer">
<div class="row">
<div class="left flex">
<input type="text" class="" placeholder="Email">
<input type="submit" class="" value="Submit">
</div>
<div class="right centered ">
<ul class="flex-column">
<li><i class="fa fa-map-marker" aria-hidden="true"></i> Address.</li>
<li><i class="fa fa-phone" aria-hidden="true"></i> Contact Info</li>
<li><i class="fa fa-clock-o" aria-hidden="true"></i> Opening Hours.</li>
</ul>
</div>
<div class="middle centered">
<p class="">School - business here</p>
</div>
</div>
</div>
</footer>
I would recommend taking the class off of footer and just use the footer tag to target the parent container. Then I would use div tags for each section instead of p tags, putting p tags inside the div. And my last recommendation, although your professor will think you're cheating, is to use flexbox. Enjoy.
Also the box-sizing: border-box; is for the padding I added to the footer so it will still be width: 100%; instead of 100% + 40px
* {
box-sizing: border-box;
}
.left {}
.centered {}
.centered p {}
.right {}
footer {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px;
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background: #052D48;
}
footer p {
margin: 0;
color: green;
font-size: 8px;
}
<footer>
<div class="left">
<p>Sign up botton here</p>
</div>
<div class="centered">
<p>1 line</p>
<p>2 line</p>
<p>3 line</p>
</div>
<div class="right">
<p>School - business here</p>
</div>
</footer>
here is one idea.
https://jsfiddle.net/gztLhdk4/2/
you can customize it more based on your needs.
<footer>
<div class="footer">
<div class="left padd">
<p>
Sign up botton here
</p>
<p>
<input type="text"> <button>sign up </button>
</p>
</div>
<div class="centered padd">
<p>
rttertertert<br>
gereryrt ytyt<br>
tryryrytru
</p>
</div>
<div class="right padd">
<div>
school
</div>
<div>
business
</div>
</div>
</div>
</footer>
.left{
text-align:left;
float:left;
}
.right{
float:right;
text-align:right;
}
.centered{
text-align:center;width:50%;float:left;
}
.footer {
position:absolute;
bottom:0;
width:100%;
height:60px;
background:#052D48;
}
.footer p {
color: #fff;
font-size: 8px;
}
.padd{padding:5px;color:#fff;}

setting an image vertically aligned with text

EDIT: Please disregard the phone/email row.
I would like to reach this kind of result:
Since I need the side texts to be as the same height of the icon, I am having some issues with the relative and absolute div wrappers and how to set them right.
HTML
<div class="row topWrapper">
<div class="iconWrapper">
<i class="fa fa-user-circle-o fa-2x"></i>
</div>
<div class="captionWrapper">
<h5><strong>Liat </strong></h5>
<h5>Your recruitment counsel</h5>
</div>
</div>
SCSS
.topWrapper {
background-color: #d9534f;
height: 150px;
.iconWrapper {
background-color: #f7ecb5;
display: inline-block;
position: relative;
width:16.67%;
i{
position: absolute;
top: 50%;
#include translate(0, -50%);
}
}
.captionWrapper{
background-color: #245580;
display: inline-block;
}
}
You don't need to use absolute position to get what you want, just a few things and you are good to go.
See code snippet:
Note: i didn't use SCSS for demonstration purpose
.topWrapper {
background-color: #d9534f;
height: 150px;
padding: 5px;
}
.iconWrapper {
display: inline-block;
font-size: 17px;
}
.captionWrapper {
display: inline-block;
}
.captionWrapper h5 {
margin: 2px;
/*reduce the margin to make the two texts aligned with the icon*/
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="row topWrapper">
<div class="iconWrapper">
<i class="fa fa-user-circle-o fa-2x"></i>
</div>
<div class="captionWrapper">
<h5><strong>Liat </strong></h5>
<h5>Your recruitment counsel</h5>
</div>
</div>

CSS image background and overlay blocking link and text input click and focus

I have the following html and css:
.icon-bar {
width: 90px;
z-index: 100;
position: absolute;
}
#overlay {
position: absolute;
background-color: rgba(0,0,0,0.8);
top:0;
left: 0;
bottom:0;
height:100%;
width:100%;
z-index: -2;
}
#cover-photo {
width:100%;height: 400px;
background:url('./assets/covers.jpg') no-repeat center center fixed;
color:#fff;
background-size:cover;
text-align: center;
z-index: -1;
}
<div class="row">
<div class="col-md-12" id="cover-photo">
<div id="overlay">
</div>
<div class="icon-bar col-md-push-10">
<a class="active" href="#"><i class="fa fa-home"></i></a>
<i class="fa fa-search"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-globe"></i>
<i class="fa fa-trash"></i>
</div>
</div>
</div>
Now the background image is appearing, as well as the overlay div as expected, the div with the icon-bar class also appears in the front, but when I try to click one of the links inside that div it does not get the click, i have set a z-index of 100 for this div but it is unclickable, please assist me on this guys
You can add pointer-events: none to the overlay div. This will allow clicking the links behind it.
I think I got your point here. What's wrong in your code is where you position <div id="overlay"></div>
It should place after the end tag of cover-photo
I also rearrange your codes and modify some it.
My advise is not to make to have negative z-index instead use smaller to greater number to overlap the property of one element to another.
#cover-photo {
width: 100%;
height: auto;
background: url('./assets/covers.jpg') no-repeat center center fixed;
color: #fff;
background-size: cover;
text-align: center;
z-index: 5;
}
.icon-bar {
width: 90px;
z-index: 100;
position: relative;
}
#overlay {
position: fixed;
background-color: rgba(0, 0, 0, 0.8);
top: 0;
left: 0;
bottom: 0;
height: 100%;
width: 100%;
z-index: 1;
}
<div class="row">
<div class="col-md-12" id="cover-photo">
<div class="icon-bar col-md-push-10">
<a class="active" href="#"><i class="fa fa-home"></i></a>
<i class="fa fa-search"></i>
<i class="fa fa-envelope"></i>
<i class="fa fa-globe"></i>
<i class="fa fa-trash"></i>
</div>
</div>
<div id="overlay"></div>
</div>
I think it is because of anchor tag it is inline tag
try to make it inline-block so it will work.
Check below link
https://jsfiddle.net/ashishbhalerao/Ldot4y96/4/
Thanks,
Ashish Bhalerao

how to get both icon and heading in same line in css

I want to icon and the headings in the same line like this:
but I still got like this:
The Code:
.icon-small i{
height: 38px;
width: 38px;
color: #fff;
background-color: #888;
border-radius: 10%;
text-align: center;
vertical-align: middle;
padding-top: 12px;
}
.icon-small + p{
margin-top: 15px;
}
.icon-small h4,
.icon-small h5{
text-align: left;
}
<div class="row">
<div class="col span-1-of-3">
<span class="icon-small">
<i class="fa fa-television"></i>
<h4>Web applications</h4>
<h5>Mobile & Tablets Ready</h5>
</span>
<p>Powerful, fast and robust web applications to cater for complex business needs.</p>
</div>
<div class="col span-1-of-3">
<span class="icon-small">
<i class="fa fa-mobile-phone"></i>
<h4>Mobile apps</h4>
<h5>For the iPhone, iPad & Android</h5>
</span>
<p>Apps that connect directly to your customers.</p>
</div>
<div class="col span-1-of-3">
<span class="icon-small">
<i class="fa fa-image"></i>
<h4> Graphic </h4>
<h5>Infographics, site designs and more</h5>
</span>
<p>Let our graphics speak the thousand words that you simply don't have the time to say.</p>
</div>
</div>
I just few things but it not worked. I used Font Awesome and responsive grid system.
I used this to reset the default styles:
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
I think you want to float the icon:
.icon-small i {
float: left;
margin-right: 10px;
/* ... */
}
And for good measure:
.icon-small + p {
clear: left;
/* ... */
}
https://jsfiddle.net/mblase75/e42rsw04/
You can either use display:inline-block on the parent and display:inline on the children - or, you can use the :before pseudoclass and position it using absolute positioning.
<div class="logo">
<div class="text">Some Text</div>
</div>
.text{
position:relative;
}
.text::before {
position:absolute;
margin-left: -30px;
background-image: url("youricon.png");
background-color: #fff;
height:<<height of your icon goes here>>;
width:<<width of your icon goes here>>;
}
OR
<div class="logo">
<div class="icon"><img src="youricon.png" alt="Logo"></div>
<div class="text">Some Text</div>
</div>
.logo{
display: inline-block;
width: 100%;
}
.icon, .text {
display:inline;
}
.text{
margin-left:10px;
}
Just use position:absolute for the icon inside the icon-text block.
.icon-small {
position: relative;
padding: 0 0 0 48px; /* 38px icon width + 10px gap between icon and text */
}
.icon-small i {
height: 38px;
width: 38px;
position: absolute;
left: 0;
top: 0;
}
Since no one suggested using flexbox
take a look into this http://jsfiddle.net/hnsd4np6/2/
<div class="row container">
<div class="col span-1-of-3 box">
<span class="icon-small">
<i class="fa fa-television"></i>
<div class="details">
<h4>Web applications</h4>
<h5>Mobile & Tablets Ready</h5>
</div>
</span>
<p>Powerful, fast and robust web applications to cater for complex business needs.</p>
</div>
<div class="col span-1-of-3 box">
<span class="icon-small">
<i class="fa fa-mobile-phone"></i>
<div class="details">
<h4>Mobile apps</h4>
<h5>For the iPhone, iPad & Android</h5>
</div>
</span>
<p>Apps that connect directly to your customers.</p>
</div>
<div class="col span-1-of-3 box">
<span class="icon-small">
<i class="fa fa-image"></i>
<div class="details">
<h4> Graphic </h4>
<h5>Infographics, site designs and more</h5>
</div>
</span>
</div>
</div>
Some of the thing newly added in the html part are
added class container to the class row
added a class box to class col span-1-of-3 to to separate each product separately
Added class details to separate the icon and its descriptions
CSS
styles for the above newly added classes
.icon-small{
display:flex;
flex-direction:row;
align-items:center;
}
.details{
padding:0 1em;
}
.box{
border:1px solid #333;
background-color:#fff;
width:300px;
padding:1em;
}
.container{
display:flex;
flex-direction:row;
flex-wrap:wrap;
border:1px solid #333;
background-color:powderblue;
}
<br>
if you want to know more about flexbox clickhere