Align image below text - html

How can I align an image below text, without the image going to the right of the text?
I'm using flexbox to display the icons/links in columns. But below that, I want the image to be centered below the paragraph of text.
I have tried using clear but no change.
a:link {
color: black;
background-color: transparent;
text-decoration: none;
font-size: 75%;
}
a:visited {
color: black;
background-color: transparent;
text-decoration: none;
font-size: 75%;
}
a:hover {
color: #9700bd;
background-color: transparent;
text-decoration: underline;
font-size: 75%;
}
a:active {
color: #9700bd;
background-color: transparent;
text-decoration: none;
font-size: 75%;
}
footer ul {
list-style: none;
text-align: center;
}
footer div div {
margin: 0 auto;
display: inline-block;
}
footer > div {
/*margin-left: 25%;*/
display: flex;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"/>
<footer>
<div>
<div>
<ul>
<li><i class="fa fa-facebook-official" aria-hidden="true"></i> Facebook</li>
<li><i class="fa fa-twitter" aria-hidden="true"></i> Twitter</li>
<li><i class="fa fa-instagram" aria-hidden="true"></i> Instagram</li>
<li><i class="fa fa-vine" aria-hidden="true"></i> Vine</li>
</ul>
</div>
<div>
<ul>
<li><i class="fa fa-youtube-play" aria-hidden="true"></i> YouTube</li>
<li><i class="fa fa-twitch" aria-hidden="true"></i> Twitch</li>
<li><i class="fa fa-soundcloud" aria-hidden="true"></i> SoundCloud</li>
<li><i class="fa fa-reddit-alien" aria-hidden="true"></i> Reddit</li>
</ul>
</div>
<div>
<ul>
<li><i class="fa fa-github" aria-hidden="true"></i> GitHub</li>
<li><i class="fa fa-stack-overflow" aria-hidden="true"></i> Stack Overflow</li>
<li><i class="fa fa-jsfiddle" aria-hidden="true"></i> JSFiddle</li>
</ul>
</div>
</div>
<hr>
<div class="footer">
<p class="footer" style="clear: right;">Oh, hello there. My name is Java. No, not the programming language! Well, this is awkward. Not much else to be said... uhm... enjoy your stay, I guess!</p>
<a href="http://itzjavacraft.tk">
<img src="/images/logo.png" alt="ItzJavaCraft" class="footer" />
</a>
</div>
</footer>
Here's a JSFiddle

The quickest solution I can think of is to apply Flexbox only to the <div> that contains your icons/links. That way, the <div> below will remain "un-flexed" and will stack as you expect:
footer {
text-align: center;
}
#footer_links {
display: flex;
}
#footer_links div {
margin: 0 auto;
display: inline-block;
}
#footer_links ul {
list-style: none;
}
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet"/>
<footer>
<div id="footer_links">
<div>
<ul>
<li><i class="fa fa-facebook-official" aria-hidden="true"></i> Facebook</li>
<li><i class="fa fa-twitter" aria-hidden="true"></i> Twitter</li>
<li><i class="fa fa-instagram" aria-hidden="true"></i> Instagram</li>
<li><i class="fa fa-vine" aria-hidden="true"></i> Vine</li>
</ul>
</div>
<div>
<ul>
<li><i class="fa fa-youtube-play" aria-hidden="true"></i> YouTube</li>
<li><i class="fa fa-twitch" aria-hidden="true"></i> Twitch</li>
<li><i class="fa fa-soundcloud" aria-hidden="true"></i> SoundCloud</li>
<li><i class="fa fa-reddit-alien" aria-hidden="true"></i> Reddit</li>
</ul>
</div>
<div>
<ul>
<li><i class="fa fa-github" aria-hidden="true"></i> GitHub</li>
<li><i class="fa fa-stack-overflow" aria-hidden="true"></i> Stack Overflow</li>
<li><i class="fa fa-jsfiddle" aria-hidden="true"></i> JSFiddle</li>
</ul>
</div>
</div>
<hr>
<div>
<p>Oh, hello there. My name is Java. No, not the programming language! Well, this is awkward. Not much else to be said... uhm... enjoy your stay, I guess!</p>
<a href="http://itzjavacraft.tk">
<img src="/images/logo.png" alt="ItzJavaCraft" />
</a>
</div>
</footer>

Related

Fontawesome alignment is not perfect

I am trying to use fontawesome as icon in some text (ul -> li ->i)
Image here
I want to align them perfectly from left to right
I tried...
HTML
<ul>
<li><i class="far fa-envelope"></i>Inbox</li>
<li><i class="fas fa-check"></i>Sent</li>
<li><i class="fas fa-exclamation"></i>Important</li>
<li><i class="far fa-file-alt"></i>Draft</li>
<li><i class="fas fa-globe"></i>All Mail</li>
<li><i class="fas fa-exclamation-triangle"></i> Spam</li>
<li><i class="far fa-trash-alt"></i>Trash</li>
</ul>
CSS
.sidebar ul{
list-style: none;
}
.sidebar ul li i{
margin-right: 5px;
float: left;
}
Give the icon a set width
ul {
list-style: none;
}
ul li i {
margin: 5px;
width: 1.5em;
text-align:center
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" rel="stylesheet"/>
<ul>
<li><i class="far fa-envelope"></i>Inbox</li>
<li><i class="fas fa-check"></i>Sent</li>
<li><i class="fas fa-exclamation"></i>Important</li>
<li><i class="far fa-file-alt"></i>Draft</li>
<li><i class="fas fa-globe"></i>All Mail</li>
<li><i class="fas fa-exclamation-triangle"></i>Spam</li>
<li><i class="far fa-trash-alt"></i>Trash</li>
</ul>
a table configuration
ul {
list-style: none;
}
ul li {
display:table-row;
}
ul li [class*="fa"] {
padding: 5px;
display:table-cell;
text-align:center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" rel="stylesheet" />
<ul>
<li><i class="far fa-envelope"></i>Inbox</li>
<li><i class="fas fa-check"></i>Sent</li>
<li><i class="fas fa-exclamation"></i>Important</li>
<li><i class="far fa-file-alt"></i>Draft</li>
<li><i class="fas fa-globe"></i>All Mail</li>
<li><i class="fas fa-exclamation-triangle"></i>Spam</li>
<li><i class="far fa-trash-alt"></i>Trash</li>
</ul>

Make list of icons responsive with Bootstrap

I have this list of icons (fonts) lined up on the bottom of a section's page. On mobile, the line of icons overflows over on the right of that page. I would like to have 3 or 4 icons per row instead on smaller screen. I have tried multiple possibilities and the best I got was the line to be cut off (not having all icons show). Any cue would be greatly appreciated, I don't know what I'm doing wrong :-/
HTML:
<!--Skills-->
<div class="container">
<div class="icons text-center">
<ul>
<li><i class="fab fa-html5"></i></li>
<li><i class="fab fa-css3-alt"></i></li>
<li><i class="fab fa-js"></i></li>
<li><i class="fab fa-bootstrap"></i></li>
<li><i class="fab fa-sass"></i></li>
<li><i class="fab fa-less"></i></li>
<li><i class="fab fa-github"></i></li>
<li><i class="fab fa-wordpress"></i></li>
<li><i class="fab fa-adobe"></i></li>
<li><i class="fab fa-python"></i></li>
</ul>
</div>
</div>
As for CSS:
/*Skills*/
.icons {
padding: 0px 0px;
}
ul {
padding: 0;
margin: 0;
display: flex;
justify-content:space-around;
width: 700px;
margin-left: auto;
margin-right: auto;
}
ul li {
list-style: none;
font-size: 30px;
border-radius: 400px;
width: 50px;
height: 50px;
display: block;
text-align: center;
padding-top: 4px;
padding-bottom: 0px;
color: #2c3e50;
}
.icons > ul li {
flex: 1;
}
form ul li {
font-size: 15px;
width: inherit;
color: #ff0000;
text-align: left;
}
form ul {
margin-left: 0px;
margin-right: 0px;
height: 10px;
}
/*What I tried so far... some of them might be nonesense but I was desperate!*/
#media (max-width: 450px) {
.icons {
padding: 25px;
width: 25%;
flex-wrap: wrap;
position: absolute;
margin:auto;
justify-content: center;
align-items: center;
display:inline-block;
text-align: center;
overflow-x: hidden;
line-height: 1.2;
width: 100%;
margin-bottom: auto;
margin-left: auto;
margin-right: auto;
}
#media (max-width: 450px) {
.icons li {
width: 50%;
}
restructure your code to remove ul, li and let the default behavior manage this for;
working snippet below:
i {
list-style: none;
font-size: 30px;
border-radius: 400px;
width: 50px;
height: 50px;
display: block;
text-align: center;
padding-top: 4px;
padding-bottom: 0px;
color: #2c3e50;
}
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.6/css/all.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
Do you really need ul, li ?
<hr/>
<div class="icons text-center">
<i class="fab fa-html5"></i>
<i class="fab fa-css3-alt"></i>
<i class="fab fa-js"></i>
<i class="fab fa-bootstrap"></i>
<i class="fab fa-sass"></i>
<i class="fab fa-less"></i>
<i class="fab fa-github"></i>
<i class="fab fa-wordpress"></i>
<i class="fab fa-adobe"></i>
<i class="fab fa-python"></i>
</div>
You could have done something this way
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
<div class="container text-center">
<span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span>
<span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span> <span style="padding:5px">
<i class="fab fa-html5"></i>
</span>
<span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span> <span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span> <span style="padding:5px">
<i class="fab fa-facebook-f"></i>
</span>
<span style="padding:5px">
<i class="fab fa-twitter"></i>
</span>
</div>

Need border around icon using flex

I'm working with borders here I want to add the border to the icon as shown in the image. so far I did this can anyone suggest me point me in the right direction
.list {
display: flex;
flex-direction: row;
width: 182px;
background: aliceblue;
}
ul {
display: flex;
flex-wrap: wrap;
list-style-type: none;
}
li {
width: 20px;
padding: 10px;
border-top: 1px solid rgba(0, 0, 0, 0.2);
border-right: 1px solid rgba(0, 0, 0, 0.2);
}
i.fa {
padding: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
</ul>
</div>
I would either use .nth-child pseudo-class of the icons to put specific borders on each one, or better yet (in my opinion) put a class on each one based on the borders it needs (.border-right, .border-bottom etc.). This makes your html a little more descriptive in terms of indicating what the class should do to the element.
The advantage of the .nth-child method is you can rearrange the elements without changing their classes and still achieve the same results. You will have to write a little more css but it's pretty straightforward stuff so that's not a real concern.
If and only if the number of icon in a single row(3) is fixed.
.list {
display: flex;
flex-direction: row;
width: 182px;
background: aliceblue;
}
ul {
display: flex;
flex-wrap: wrap;
list-style-type: none;
}
li {
width: 20px;
padding: 10px;
border-right: 1px solid rgba(0, 0, 0, 0.2);
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
li:nth-child(3n+3) {
border-right: 0;
}
i.fa {
padding: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet" />
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
</ul>
</div>
Making use of solid colour and negative margins you can achieve that easily. please have a look at the below working snippet, hope it help :)
.list {
display: flex;
flex-direction: row;
width: 182px;
background: aliceblue;
}
ul {
display: flex;
flex-wrap: wrap;
list-style-type: none;
}
li {
width: 20px;
padding: 10px;
border: 1px solid #ccc;
margin: -1px -1px 0 0;
}
i.fa {
padding: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
</ul>
</div>
above answer was my personal opinion to have a better ui design, in order to achieve the result as per the screenshot you can do that by using table tag and few lines of css as shown in the below code snippet. it has it's own catch of having rows, which you need to control :)
table {
border-collapse: collapse;
border-style: hidden;
}
table td {
border-width: 1px;
border-style: inset;
border-color:#ccc;
padding: 10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<table>
<tr>
<td><i class="fa fa-facebook" aria-hidden="true"></i></td>
<td><i class="fa fa-twitter" aria-hidden="true"></i></td>
<td><i class="fa fa-pinterest-p" aria-hidden="true"></i></td>
</tr>
<tr>
<td><i class="fa fa-dribbble" aria-hidden="true"></i></td>
<td><i class="fa fa-google-plus" aria-hidden="true"></i></td>
<td><i class="fa fa-whatsapp" aria-hidden="true"></i></td>
</tr>
<tr>
<td><i class="fa fa-github" aria-hidden="true"></i></td>
</tr>
</table>
Please try following code. also you can add more icon looking good design
.list {
display: flex;
flex-direction: row;
width: 182px;
background: aliceblue;
}
ul {
padding: 0;
margin: 0 0 40px 0;
overflow: hidden;
width: 100%;
flex-wrap: wrap;
display: flex;
}
li {
width: 33.33%;
-webkit-box-flex: 0;
-ms-flex: 0 0 25%;
flex: 0 0 33.33%;
max-width: 33.33%;
display: inline-block;
text-align: center;
border-bottom: 1px solid #000;
margin-bottom: -1px;
padding: 10px;
border-left: 1px solid #000;
margin-bottom: -1px;
}
li:nth-child(3n-5) {
border-left: none;
}
li:nth-child(n+2) {
border-right: none;
}
i.fa {
padding: 5px;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
<li><i class="fa fa-instagram" aria-hidden="true"></i></li>
</ul>
</div>
Here is an idea using pseudo element and one border. You add border-right to only the first and second element of each row and for each first element starting from the second row you add a whole line on the top that will cover the row.
.list {
display: inline-flex;
margin:5px;
flex-direction: row;
width: 182px;
background: aliceblue;
}
ul {
display: flex;
flex-wrap: wrap;
list-style-type: none;
}
li {
width: 20px;
padding: 10px;
position:relative; /*Don't forget this*/
}
/*The magic starts here */
li:not(:nth-child(3n + 3)) {
border-right: 1px solid rgba(0, 0, 0, 0.2);
}
li:nth-child(3n + 4):before {
content:"";
position:absolute;
top:0;
left:0;
width:120px;
height:1px;
background:rgba(0, 0, 0, 0.2);
}
/**/
i.fa {
padding: 5px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet"/>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
</ul>
</div>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
</ul>
</div>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
</ul>
</div>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
</ul>
</div>
<div class="list">
<ul>
<li><i class="fa fa-facebook" aria-hidden="true"></i></li>
<li><i class="fa fa-twitter" aria-hidden="true"></i></li>
<li><i class="fa fa-pinterest-p" aria-hidden="true"></i></li>
<li><i class="fa fa-dribbble" aria-hidden="true"></i></li>
<li><i class="fa fa-google-plus" aria-hidden="true"></i></li>
<li><i class="fa fa-whatsapp" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
<li><i class="fa fa-github" aria-hidden="true"></i></li>
</ul>
</div>
By the way you are doing this, I think the easiest solution for you would be to target specifically the 5th and 6th child elements. You can do this with the nth-child(n) css selector - so li:nth-child(5) to target the G+ icon box for example, and then just add the style for a bottom border. More information: https://www.w3schools.com/CSSref/sel_nth-child.asp

Clickable icon with link

I have an icon list made of social media but they're only clickable on the letter of the icon, I want it to be clickable on any spot but I have to click on the "F" of facebook:
On the facebook icon, I have to click literally on the "F", it doesn't work if I click on the blue spot, how can I fix this? Here's my code:
<div class="leftside">
<ul class="socialmediaicons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-youtube"></i></li>
</ul>
</div>
A possible workaround will be using css. anchor is inline element and it only wraps the icon. We need anchor to cover whole area in li
using css
ul li a{
display:inline-block;
width:100%;
height:100%;
}
li{
border:1px solid red;
display: inline-block;
}
.fa{
padding:15px;
padding-bottom: 15px;
padding-top:15px;
}
a{
display: block;
}
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="leftside">
<ul class="socialmediaicons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-youtube"></i></li>
</ul>
</div>
</body>
</html>
<html>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
li{
border:1px solid red;
display: inline-block;
}
.fa{
padding:15px;
padding-bottom: 15px;
padding-top:15px;
}
a{
display: block;
}
</style>
</head>
<body>
<div class="leftside">
<ul class="socialmediaicons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-youtube"></i></li>
</ul>
</div>
</body>
</html>
I would use inherit for de with and height of the li items. I used flexbox to align everything in the center. When hyperlinks are created for the other icons, you can remove the flexbox settings for li.
li {
width: 50px;
height: 50px;
background-color: pink;
border: thin solid black;
list-style: none;
display: flex;
justify-content: center;
align-items: center;
}
li>a {
width: inherit;
height: inherit;
display: flex;
justify-content: center;
align-items: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<div class="leftside">
<ul class="socialmediaicons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-instagram"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-youtube"></i></li>
</ul>
</div>

Removing Space Between Anchor Tags [duplicate]

This question already has answers here:
How to remove the space between inline/inline-block elements?
(41 answers)
Closed 5 years ago.
I'm having some troubles removing the white space between these 'social links' that I'm making.
Also I am having some troubles getting them centered correctly in the middle of the 'a' tag. I've tried using: margin: -30; or padding: -30 to try to pull the <i> tags closer to the top, which didn't work!
Why isn't this this working?
Here is my code:
#footer .footer-right {
float: right;
margin-right: 50px;
margin-top: 20px;
}
#footer .footer-right a {
height: 55px;
width: 55px;
text-align: center;
color: black;
padding: 5px 5px;
display: inline-block;
font-size: 3em;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="footer-right">
<div class="social-links">
<div class="social-row soc-row-1">
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-github" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
<div class="social-row">
<i class="fa fa-stack-overflow" aria-hidden="true"></i>
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-youtube" aria-hidden="true"></i>
</div>
</div>
</div>
Using display: inline-block introduces a margin between elements. Give a negative right margin to remove space.
#footer .footer-right a {
height: 55px;
width: 55px;
text-align: center;
color: black;
padding: 5px 5px;
display: inline-block;
font-size: 3em;
margin-right: -4px;
}
The amount of margin depends on the font size of the parent.
Another method is to skip the closing tag:
<a href="#" class="twitter"><i class="fa fa-twitter" aria-hidden="true"></i>
<a href="#" class="github"><i class="fa fa-github" aria-hidden="true"></i>
<a href="#" class="linkedin"><i class="fa fa-linkedin" aria-hidden="true"></i>
.footer-right {
margin-top: 20px;
}
.footer-right a {
height: 55px;
width: 55px;
text-align: center;
color: black;
padding: 5px 5px;
display: inline-block;
font-size: 3em;
margin-right: -4px;
}
.social-row{
text-align: center;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="footer-right">
<div class="social-links">
<div class="social-row soc-row-1">
<i class="fa fa-twitter" aria-hidden="true"></i>
<i class="fa fa-github" aria-hidden="true"></i>
<i class="fa fa-linkedin" aria-hidden="true"></i>
</div>
<div class="social-row">
<i class="fa fa-stack-overflow" aria-hidden="true"></i>
<i class="fa fa-facebook" aria-hidden="true"></i>
<i class="fa fa-youtube" aria-hidden="true"></i>
</div>
</div>
</div>