how to make the borders of icons equal sized - html

I have footer which has few icons.These icons have border around them.
The problem is that based on the icon,the border size is getting changed.But I need border with equal sizes for all the icons.
Could any one help me with this.
<div class="site-footer">
<div class="row">
<div class="col-lg-6">
<p class="box-1">
You can visit us at <span class="link-webiste" style="size: 70px !important;">agoodtreeproduction.com</span></p>
</div>
<div class="col-lg-6">
<h3 style="color: white;"> Around The Web</h3>
<ul class="list-inline">
<li class="footer-elements">
<i class="fa fa-facebook btn-outline icon" aria-hidden="true"></i>
</li>
<li class="footer-elements">
<i class="fa fa-twitter btn-outline icon" aria-hidden="true"></i>
</li>
<li class="footer-elements">
<i class="fa fa-google-plus btn-outline icon" aria-hidden="true"></i>
</li>
<li class="footer-elements">
<i class="fa fa-linkedin btn-outline icon" aria-hidden="true"></i>
</li>
</ul>
</div>
</div>
</div>
css
li {
display: inline;
}
.site-footer{
background-color: #6E2607;
//display: flex;
}
.box{
height:100px;
min-width: 200px;
}
.One{
//background-color: blue;
}
.two{
//background-color: yellow;
}
.box-1{
color: white !important;
}
.footer-elements{
padding: 20px;
}
.icon{
font-size: 30px !important;
}
.btn-outline{
color:#fff;
background:0;
border-style:solid;
border-radius:50%;
transition: background-color 0.7s ease-in-out;
margin-top: 5px;
padding: 25px;
}
.btn-outline:hover{
background-color: #000000;
}
Demo here:
https://jsfiddle.net/VijayVj7/zadx4rec/

Add a border-width to .btn-outline so it becomes:
.btn-outline{
color:#fff;
background:0;
border-style:solid;
border-radius:50%;
border-width: 20px;
transition: background-color 0.7s ease-in-out;
margin-top: 5px;
padding: 25px;
}
Where you change 20px to whatever you need it to be.

Creating equal widths for elements in the same row, while still allowing those elements to be flexible based on their content, is a good job for flexbox. As seen in this answer, you can set the parent element to display: flex, and each of your <li> tags to have flex-basis: 0 and flex-grow: 1. This is saying that each list item will start with no width, and what available growth there is will be equally distributed among all of them.
However, this setup is still going to make each item grow at least enough to fit its content. So you may have to use media queries to shrink your font size for the icons on smaller screens (otherwise you may end up outside the viewport, or longer text forcing a wider element), and/or consider setting flex-wrap: wrap on the parent (which would start a new line of icons once they can't be squeezed down any more).
Finally, I added box-sizing: border-box to the icons, so they account for padding with their widths. If you're not too far into the project, consider adding that declaration to the * selector (currently commented out), since it's generally seen as a more logical box model for elements.
The fiddle.

Related

How to make <a> tag take 100% height of <li> element

I am struggling to make my <a> take 100% height of <li> element and i want to do this because when i hover over <a> i want it to get background color and to change its color to white.
this is how it should look like
I have tried giving my <a> height:100%
but this is my result
on second picture i cut out the piece and zoomed it in so you guys can see better
i found one answer on other stack overflow thread where you would give <ul> display:table and give height:0 and then give <li> height:100% but it doesnt work for me.
PLEASE NOTE THAT IM USING BOOTSTRAP 4.0.0alpha and SASS(SCSS)
HTML
<div class="topContact hidden-md-down">
<div class="container">
<div class="row">
<ul class="contactInfo">
<li class="d-inline-block"><i class="far fa-envelope"></i>info#reen.com</li>
<li class="d-inline-block"><i class="fas fa-mobile-alt"></i>+00 (123) 456 78 90</li>
</ul>
<ul class="socialIcons ml-auto">
<li class="d-inline-block"><i class="fab fa-facebook-f"></i></li>
<li class="d-inline-block"><i class="fab fa-google-plus-g"></i></li>
<li class="d-inline-block"><i class="fab fa-twitter"></i></li>
<li class="d-inline-block"><i class="fab fa-pinterest-p"></i></li>
<li class="d-inline-block"><i class="fab fa-behance"></i></li>
<li class="d-inline-block"><i class="fab fa-dribbble"></i></li>
</ul>
</div>
</div>
</div>
SCSS
.topContact{
background-color: #f5f7fa;
border-bottom: 1px solid #e6e9ed;
ul{
padding:0px 15px 0px 15px;
margin:0;
}
a:hover{
background: indigo;
}
a{
height: 100%;
}
.contactInfo li,
.contactInfo a,
.socialIcons a{
font-size: 10pt;
color: #506a85;
}
.contactInfo a:hover{
text-decoration: none;
color: #00bc9c;
}
.contactInfo svg,{
margin-right: 8px;
}
.contactInfo li{
padding-right: 20px;
}
}
In order for a child element to assume 100% height of the parent element, the parent element must have its size set. Its not enough to give your <li> element a font size for its <a> child to extend its height to cover it. The <li> must inherit the height from its parent or have it defined. Also, your <a> element must be a block or inline-block element to accept height.
Try:
<style type="text/css">
ul#socialIcons, ul#socialIcons>li { margin:0px; padding:0px; list-style:none; }
ul#socialIcons>li>a { display:block; font-size:1em; margin:0px; padding:0.5em; }
</style>
Also I recommend that you take a look at the concept of HTML box model: https://www.w3schools.com/css/css_boxmodel.asp

icon bar customisation in html and css

I am trying to customise the following icon bar (as shown in w3schools) - code pasted below along with link, to display like the image shown. The icons need to have text right underneath them (labels). This is NOT trivial as you'll see if you continue to read the description of the problem.
Furthermore, I'd like to add hover-over text to these icons, as shown.
Any solutions/suggestions appreciated.
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_icon_bar_h
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {margin:0;}
.icon-bar {
width: 100%;
background-color: #666;
overflow: auto;
}
.icon-bar a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #000;
}
.active {
background-color: #44444 !important;
}
</style>
<body>
<div class="icon-bar">
<i class="fa fa-user"></i>
<i class="fa fa-mortar-board"></i>
<i class="fa fa-eye"></i>
<i class="fa fa-download"></i>
</div>
</body>
</html>
In the image shown, the icon bar is placed over a green background image. I would like the text to appear directly underneath, and for there also to be hover-over text to appear.
I have tried the below, but it is incredibly difficult to get the layout correct. Is there a better way?
<div class="icon-bar">
<i class="fa fa-user"></i>
<i class="fa fa-mortar-board"></i>
<i class="fa fa-eye"></i>
<i class="fa fa-download"></i>
</div>
<br>
<br>
<br>
<br>
<br>
<br>
<br><br>
<br>
<br>
<br>
<br>
<p><font color="white">Topic1 Topic2 Topic3 Topic4</font></p>
<br>
<br>
<br>
<br>
Furthermore, a design flaw with adding text that way is on mobile sites the formatting will be entirely lost. see image below.
Any ideas to most effectively do this would be a great help!
this is for the w3 school code
I just changed the way of writing the icon and the text .
its not possible to look the iconbar same way in all screen size either put dropdown button or vertical display ,I have written that for vertical display ,. I havent changed padding . Since i dont know much what you want
I can help you with bootstrap if you want in bootstrap i think that will be easy for you .
<!DOCTYPE html>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-
awesome/4.7.0/css/font-awesome.min.css">
<style>
body {margin:0;}
.icon-bar {
width: 100%;
background-color: #555;
overflow: auto;
}
.icon-bar a {
float: left;
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
.icon-bar a:hover {
background-color: #000;
}
.icon-bar a{
text-decoration:none;
}
.active {
background-color: #4CAF50 !important;
}
#media only screen and (max-width: 700px) {
.icon-bar a {
width:100% !important;
}
}
</style>
<body>
<div class="icon-bar">
<a class="active" href="#">
<ul style="list-style:none">
<li><i class="fa fa-home"></i></li>
<li>home</li>
</ul>
</a>
<a href="#">
<ul style="list-style:none" class="menu_ul">
<li><i class="fa fa-search"></i></li>
<li>search</li>
</ul>
</a>
<a href="#">
<ul style="list-style:none" class="menu_ul">
<li><i class="fa fa-envelope"></i></li>
<li>mail</li>
</ul>
</a>
<a href="#">
<ul style="list-style:none" class="menu_ul">
<li><i class="fa fa-globe"></i></li>
<li>web</li>
</ul>
</a>
<a href="#">
<ul style="list-style:none" class="menu_ul">
<li><i class="fa fa-trash"></i></li>
<li>delete</li>
</ul></a>
</div>
</body>
Try this,
.icon-bar{
width: 100%;
display: flex;
justify-content: space-evenly;
align-items: center;
}
.icon-bar a {
width: 20%;
text-align: center;
padding: 12px 0;
transition: all 0.3s ease;
color: white;
font-size: 36px;
}
This will affect all the a tags of .icon-bar class.
Also here's some documentation on how display flex works, https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Anchor image issue in css

I have tried lot but did not find any solution so that that can be helpful for me. I have a menu which look like as below. The Menu has multiple menu item and each item is an anchor that consists of image, text and arrow.
Problem:
Image height will fit according to anchor height and every element
of anchor must be middle.
Arrow would be down or right, every arrow will fit to right.
HTML CODE:
<a href="javascript:void(0);" class="" data-toggle="dropdown">
<span>
<img src="http://www.wpclipart.com/toys/blocks/abc_blocks.png" alt="" />ADMIN
<i class="fa fa-caret-down"></i>
</span>
</a>
CSS CODE:
a {
text-decoration: none;
width: 300px;
border: 1px solid red;
}
img {
width: 1.5em;//do not fix.
}
a:hover {
text-decoration: none;
}
plunker
Here is the working solution:
<a href="javascript:void(0);" class="" data-toggle="dropdown">
<img src="http://www.wpclipart.com/toys/blocks/abc_blocks.png" alt="" /> ADMIN
<div>
<i class="fa fa-caret-down"></i>
</div>
</a>
And the CSS:
a {
text-decoration: none;
width: 300px;
border: 1px solid red;
display:inline-block;
line-height: 1.5em;
}
a div{
display:inline-block;
float:right;
}
img {
height: 1em;
vertical-align:middle;
}
The trick here is to use the line-height on anchor tag along with vertical-align:middle on the img.
Note that you cannot use // for commenting in CSS. Only /*... */ is supported.
Here is the demo.

Icon over image + y axis positioning

I am trying to get my 5 Font Awesome Icons over my background image with a fixed position. That fixed position should allow me to scroll past it whitout any problem. I know that there is a way but i am not finding it.
My HTML:
<!--Kaffe abschnitt -->
<!--5 Icons-->
<ul>
<li><i class="fa fa-cog fa-5x"></i></li>
<li><i class="fa fa-rebel fa-5x"></i></li>
<li><i class="fa fa-empire fa-5x"></i></li>
<li><i class="fa fa-twitch fa-5x"></i> </li>
<li><i class="fa fa-steam fa-5x"></i> </li>
</ul>
<!--Ende 5 Icons-->
<!--Hintergrund-->
<img src="img/bild2.png" class="container-full">
<!--Ende Kaffe abschnitt -->
Background CSS:
.container-full {
margin: 0 auto;
width: 100%;
z-index: -999;
}
Icon CSS:
ul li {
list-style-type: none;
float: left;
}
ul li a span {
background: transparent;
color: #205D7A;
width: 240px;
height: 240px;
border-radius: 50%;
border: 2px solid;
text-align: center;
transition: all 0.2s ease-in-out;
z-index: 998;
}
ul li a span:hover {
opacity: .8;
}
I am not asking for a premade full code. Just the name of the actions or some short code snipeds.
I am trying to get my 5 Font Awesome Icons over my background image with a fixed position.
You don't want to use 'position:fixed' if you want to scroll past them.
Instead, use position:absolute.
absolute will position elements according to the first parent that has anything but "position:static", i suggest setting "position:relative" on the parent you want your elements to position them self according to.
If you want your "icons" to be along the right hand side of a div, then it would have looked like this
#myDiv{position:relative;} //the container
.myIcons{position:absolute; right:0} //a handy class on all your icons spans/i
.icon1{top:0px} //these are just unique classes per icon
.icon2{top:20px}
.icon3{top:40px}
Hope this gets you in the righth direction

How to align list Items with font-awesome icon next line text?

A picture paints a thousand words. The text on the next line needs to align on same margin as above.
HTML:
<ul>
<li>
<p><em class="fa fa-square"></em><span>Name and surnafdddddddddddddds sdgfh dh hdfh df hdsh dfh dsfh sdfhdsfh sdf hsdfhdsfhme</span></p>
</li>
</ul>
CSS:
ul{
display: table;
a{
padding-left: 10px;
}
span{
padding-left: 10px;
}
}
Update:
After #panther update:
It is acceptable, however the fontawesome icon is now off centre.
You can try to use font awesome's built-in solution for lists:
Use fa-ul and fa-li to easily replace default bullets in unordered lists.
In your case, the code will change to something like this:
<ul class="fa-ul">
<li><i class="fa fa-square"></i><span>Name and surnafdddddddddddddds sdgfh dh hdfh df hdsh dfh dsfh sdfhdsfh sdf hsdfhdsfhme</li>
</ul>
You are probably looking for st. like this.
em {float: left;}
a, span {margin: 0 0 0 20px; display: block;}
Why not do these:
Apply position with a property value of relative to li to avoid overlap
Insert the square with :before selector and add position with a property value of Absolute o its block of CSS.
That way you can position it as needed. You have top, bottom, left, and right properties to work with as you position it.
HTML
<ul>
<li>
<p>Some important text are to be place here.
It may or may not longer than the text we have here. You never know.
</p>
</li>
</ul>
CSS
ul{
list-style-type: none;
}
li {
position: relative; /* Will help curtail overlap */
padding-left: 20px; /* Reserves a space for the square dot */
}
li:before {
content: '\f0c8';
position: absolute;
left: 0; /* Places the square dot at the space created by the LI padding */
font-family: fontAwesome;
}
See working example here
i think you are expecting like this
Fiddle
http://jsfiddle.net/myYUh/88/
I have added some example found on jsfiddle, i work around little bit. it might help you.
CSS
.icons-ul{
width:100px;
}
.icons-ul>li {
position: relative;
}
icons-ul {
margin-left: 2.142857142857143em;
list-style-type: none;
}
ul, ol {
margin-top: 0;
margin-bottom: 10px;
}
.icons-ul .icon-li {
position: absolute;
left: -2.142857142857143em;
width: 2.142857142857143em;
text-align: center;
line-height: inherit;
}
[class^="icon-"], [class*=" icon-"] {
display: inline;
width: auto;
height: auto;
line-height: normal;
vertical-align: baseline;
background-image: none;
background-position: 0% 0%;
background-repeat: repeat;
margin-top: 0;
}
HTML
<ul class="icons-ul">
<li><i class="icon-li icon-ok"></i>Bulleted lists (like this one)</li>
<li><i class="icon-li icon-ok"></i>Buttons</li>
<li><i class="icon-li icon-ok"></i>Button groups</li>
<li><i class="icon-li icon-ok"></i>Navigation</li>
<li><i class="icon-li icon-ok"></i>Prepended form inputs</li>
<li><i class="icon-li icon-ok"></i>…and many more with custom CSS</li>
</ul>
Late replay but check how I solved it.
ul li{ display: flex; padding: 10px 0; }
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.0/css/all.min.css"
/>
<ul>
<li>
<i class="fa-solid fa-check"></i>
Font Awesome is the internet's icon library and toolkit used by millions of
designers, developers, and content creators.
</li>
<li>
<i class="fa-solid fa-check"></i>
Font Awesome is the internet's icon library and toolkit used by millions of
designers, developers, and content creators. Font Awesome is the internet's
icon library and toolkit used by millions of designers, developers, and
content creators.
</li>
<li>
<i class="fa-solid fa-check"></i>
Font Awesome is the internet's icon library and toolkit
</li>
<li>
<i class="fa-solid fa-check"></i>
Font Awesome is the internet's icon library and toolkit used by millions of
designers, developers, and content creators.
</li>
</ul>