This is the section of my code that doesn't work:
.copyright {
display: flex;
flex-wrap: nowrap;
/* This is not working */
color: red;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<p>Sample</p>
<span>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#3b5998"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</li>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#00aced"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</li>
</span>
<br><br>
<p class="copyright">
<span>I want this left from icons</span>
<span>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#3b5998"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</li>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#00aced"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</li>
</span>
</p>
Do you know why flexwrap: nowrap; isn't working? My icons are below the span instead of being placed to the right.
It's not working because flex-wrap: nowrap applies to flex items, not the text inside the item. You need to target the text with white-space: nowrap.
.copyright {
display:flex;
flex-wrap: nowrap; /* will prevent flex items on the same line from wrapping */
white-space: nowrap; /* will prevent text from wrapping */
}
jsFiddle demo
Just give your copyright class display: inline-block;
Just need a common wrapper such a div and display flex
div {
display: flex;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<p>Sample</p>
<span>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#3b5998"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</li>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#00aced"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</li>
</span>
<br><br>
<p class="copyright">
<div>
<span>I want this left from icons</span>
<span>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#3b5998"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</li>
<li class="fa-stack">
<i class="fa fa-square fa-stack-2x" style="color:#00aced"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</li>
</span>
</div>
</p>
I just needed to update <p class="copyright"> with <div class="copyright">
Or I could use display:block for the p.copyright
which ever elements or icons you want to see in a line and in order, then place those in a div element which is having flex.
and you dont need flex-wrap property as with proper html order ,just a display:flex property will take care of most of the things
See here https://jsfiddle.net/b6vw9t2y/38/
<div style='display: flex'>
<i>icon1></i>
<i>icon2</i>
<i>icon3</i>
</div>
output: icon1 icon2 icon3
go through below link for flexbox basics , its understandable and it will surely makes ur life much easier when u get the grip of flexbox
https://www.w3schools.com/css/css3_flexbox.asp
Related
So I've been trying to do a quick animation that replaces an entire span on hover but I can't seem to get it to work. How should I approach going about replacing a span on hover?
<h1>I need this replaced...</h1>
<span class="fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
<h1>to this</h1>
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-flag fa-stack-1x fa-inverse"></i>
</span>
<h1>on hover</h1>
Sample CodePen here.
By changing the :before css properties for the twitter on hover you can achieve the output.
span.fa-stack:hover i.fa-twitter:before{content:"\f024"; color:#fff}
span.fa-stack:hover i.fa-square-o:before{content:"\f111"}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<h1>I need this replaced...</h1>
<span class="fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
You can achieve this in CSS by combining the :hover and :first-child/:last-child CSS selectors.
.fa-stack.fa-lg:hover :first-child:before {
content: "\f111";
}
.fa-stack.fa-lg:hover :last-child:before {
content: "\f024";
color: #fff;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<span class="fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
I have been at this for way too long and have yet to figure out how to stack four font-awesome icons on top of each other. I've gotten to three but I am wanting my icons to look like this (sorry for crummy image)
Here's the HTML for my three stacked.
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x icon-background4"></i>
<i class="fa fa-circle-thin fa-stack-2x icon-background6"></i>
<i class="fa fa-cutlery fa-inverse fa-stack-1x"></i>
</span>
The CSS
.icon-stack-1x {
line-height: inherit;
}
.icon-stack-2x {
font-size: 1.5em;
}
set display:flex on .fa-cutlery and .fa-inverse to .fa-circle-thin
and background-color to span
body {
background: red
}
span {
background: black;
border-radius: 100%
}
.fa-cutlery {
display: flex
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<span class="fa-stack fa-4x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-circle-thin fa-stack-2x fa-inverse"></i>
<i class="fa fa-cutlery fa-inverse fa-stack-1x"></i>
</span>
I am trying to create a responsive 2x2 grid of Font Awesome icons with text beneath, both centered within their containing li element. I'm currently trying to use a method that I used when I was doing something similar with images within a list using Flexbox but it doesn't seem to work the same.
Here is my current HTML:
<section id="services">
<h2>What we do best:</h2>
<ul class="fa-ul">
<li>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-wrench fa-stack-1x fa-inverse"></i>
</span>
<p>Application Support</p>
</li>
<li>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-users fa-stack-1x fa-inverse"></i>
</span>
<p>User Training</p>
</li>
<li>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-headphones fa-stack-1x fa-inverse"></i>
</span>
<p>SharePoint Consulting</p>
</li>
<li>
<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-magic fa-stack-1x fa-inverse"></i>
</span>
<p>Custom Development</p>
</li>
</ul>
</section>
And CSS:
#services{
margin: 0 auto;
}
#services h2{
margin-left: 1rem;
margin-top: 0;
padding-top: 2rem;
}
#services ul{
display: flex;
flex-flow: row wrap;
}
#services li{
margin: .55rem;
font-size: .85rem;
flex-basis: calc(50% - 20px);
}
.fa-circle{
color: #30C0D8;
}
That code has gotten me here:
Will this method work for this situation or is there a better way? For some reason, as a side note, when I expand the window my 2nd column of icons moves whereas the 1st column of icons stay put. Any ideas why that would be? Here's a screenshot:
Thank you!
I think text-align: center; will help you for #services li
I'm having trouble getting the correct styling for my footer. I've managed to get the correct styling for mobile but for tablet and desktop I'm having a few issues. I'm trying to get the social icons to be centred horizontally off to the right-hand side of the footer. I'm not sure why the have the current set location. Any help in figuring this out would be helpful.
This image shows what I'm trying to achieve for the desktop version. I'm not sure how to do it with out using a fixed margin position which isn't what I want to do as it only then works in chrome and then looks bad in other browsers?
enter link description here
<footer>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6">
<p class="copyright text-muted">Copyright © Eat Sleep Kayak 2015</p>
</div>
<div class="footersocialicons col-xs-12 col-sm-6">
<ul class="list-inline">
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-google fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-youtube fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</footer>
/* Footer */
#media (max-width:768px){
footer {text-align: center; padding: 5px;}
}
#media (min-width: 769px) {
footer .list-inline {
float: right;
position:relative;top:50% ;
transform:translateY(-50%);
}
footer .copyright {
float: left;
}
}
footer {
font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
/*background-color: #eee;*/
background-color: #6B6A67;
padding-top: 5px;
}
footer .copyright {
font-size: 14px;
}
footer .list-inline {
height: 100%;
}
Add the class .text-center to this line - <div class="footersocialicons col-xs-12 col-sm-6"> to center everything inside.
Try adding a fixed height and line-height to your footer. You also said you wanted the icons to the right, so you add the .text-right class to do that.
The following centers the footer text and icons horizontally and aligns the icons to the right.
<style>
footer {
height: 60px;
line-height: 60px;
}
</style>
<footer>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-6">
<p class="copyright text-muted">Copyright © Eat Sleep Kayak 2015</p>
</div>
<div class="footersocialicons col-xs-12 col-sm-6 text-right">
<ul class="list-inline">
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-google fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
<li>
<a href="#">
<span class="fa-stack fa-lg">
<i class="fa fa-circle fa-stack-2x"></i>
<i class="fa fa-youtube fa-stack-1x fa-inverse"></i>
</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</footer>
Fiddle: http://jsfiddle.net/timgavin/mas4dg0y/
I add fontawesome icon with square this worked for me:
HTML:
<ul class="list-inline">
<li><a href="#">
<span class="fa-stack fa-lg icon-facebook">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x"></i>
</span>
</a></li>
<li><a href="#">
<span class="fa-stack fa-lg icon-twitter">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
</a></li>
<li><a href="#">
<span class="fa-stack fa-lg icon-gplus">
<i class="fa fa-square fa-stack-2x"></i>
<i class="fa fa-plus fa-stack-1x"></i>
</span>
</a></li>
</ul>
CSS:
.fa-stack-1x {
color:white;
border-radius:0;
}
.fa-square{
border-radius:0;
}
.icon-facebook {
color:#3b5998;
}
.icon-twitter {
color:#00aced;
}
.icon-gplus{
color:#dd4b39;
}
body {
background-color: black;
}
I need to show square without border radius and I add border-radius:0; for class .fa-square But font awesome not work without border radius.
how do can i fix this ?
DEMO JSFIDDLE
As others mentioned the "square" behind the icon is actually a font icon applied to .fa-square:before in the css.
Unfortunately the Font Awesome set at this time does not contain a true square.
However they do have an icon in their set with much harder corners called the "stop" icon (in the video player icon group). You can substitute this for the "square" in your css to get a much better square stack by doing this. It does make a very slight radius corner, but at small sizes it's hardly noticable:
.fa-square:before {
content: "\f04d";
}
"\f04d" is the CSS content value for the stop icon in Font Awesome.
List of CSS content values for Fontawesome Icons
http://astronautweb.co/snippet/font-awesome/
Results
Image of results
Cheers!
fa-square:before{content:"\f0c8"} is going to cause an issue. You can fix it by removing that class. Then overriding the border-radius for each of the fa-stack-1x icons.
<ul class="list-inline">
<li><a href="#">
<span class="fa-stack fa-lg icon-facebook">
<i class="fa fa-facebook fa-stack-1x"></i>
</span>
</a>
</li>
<li><a href="#">
<span class="fa-stack fa-lg icon-twitter">
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
</a>
</li>
<li><a href="#">
<span class="fa-stack fa-lg icon-gplus">
<i class="fa fa-plus fa-stack-1x"></i>
</span>
</a>
</li>
</ul>
CSS:
body {
background-color: black;
}
.fa-stack-1x {
-webkit-border-radius: 18px;
-moz-border-radius: 18px;
border-radius: 18px;
color:white;
}
.icon-facebook>.fa-stack-1x {
background-color:#3b5998;
}
.icon-twitter>.fa-stack-1x {
background-color:#00aced;
}
.icon-gplus>.fa-stack-1x {
background-color:#dd4b39;
}
For squares just change the border-radius's to 0px; in the above CSS
I looked into font-awesome.min.css and found this line: fa-square:before{content:"\f0c8"} I believe that means you are using \f0c8 to draw the square. That means it is a character from awesome font and you can't change it by border-radius.
You can read about this icon at
http://www.utf8icons.com/character/61640/UTF-8-character