Bootstrap 4, CSS - Hide Text on a tab menu - html

I have a CSS issue hiding the text in my side menu and leave the font awesome icons on mobile view, and I can't think of any reasonable solution. I use bootstrap 4
Then code of my sidebar menu
<div class="sidebar">
<a class="active" href="#Link0"><i class="fas fa-walking"></i> Link0</a>
<i class="fas fa-users"></i> Link1
<i class="fas fa-cog"></i> Link2
<i class="fas fa-headset"></i> Link3
</div>
According to the bootstrap manual, I should be able to hide any element between any suitable tag with class="d-SM-none d-MD-block". My problem is that I want the icon on the left-hand side to stay visible for mobile view and hide the text but when I put the text between <div> tags text always appears one line down from the icon. I tried <i> <p> tags and still the same issue and btw the text doesn't hide anyways :D
Any help welcome!
What I tried and didn't work:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
<div class="sidebar">
<a class="active" href="#Link0"><i class="fas fa-walking"></i> <div class="d-sm-none d-md-block">Link0</div></a><!--Text is one line down from icon-->
<i class="fas fa-users"></i><p class="d-sm-none d-md-block"> Link1</p><!--Text is one line down from icon-->
<i class="fas fa-cog"></i> Link2
<i class="fas fa-headset"></i> Link3
</div>

The hidding part works fine, the problem is that you try to add some elements that are default display with block (div, p) so replace that by span.
Then don't use class d-md-block as you are in a that has a default display: inline. So you should use class d-md-inline.
Result:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" integrity="sha512-iBBXm8fW90+nuLcSKlbmrPcLa0OT92xO1BIsZ+ywDWZCvqsWgccV3gFoRBv0z+8dLJgyAHIhR35VZc2oM/gI1w==" crossorigin="anonymous" />
<div class="sidebar">
<a class="active" href="#Link0"><i class="fas fa-walking"></i> <span class="d-sm-none d-md-inline">Link0</span></a><!--Text is one line down from icon-->
<i class="fas fa-users"></i><span class="d-sm-none d-md-inline"> Link1</span><!--Text is one line down from icon-->
<i class="fas fa-cog"></i> Link2
<i class="fas fa-headset"></i> Link3
</div>

Related

Icons not showing properly showing empty boxes

I embedded cdn link on my html header and it's not showing any kind of icon, it's showing an empty box please check this code snippet and its result to know what i mean. any help would be appreciated. the link was given by font awesome via email upon registration
<script src="https://use.fontawesome.com/44c6a45abc.js"></script>
<i class="fa-solid fa-user"></i>
<!-- regular style -->
<i class="fa-regular fa-user"></i>
<!-- light style -->
<i class="fa-light fa-user"></i>
<!-- duotone style -->
<i class="fa-duotone fa-user"></i>
<!-- all new thin style -->
<i class="fa-thin fa-user"></i>
<!--brand icon-->
<i class="fa-brands fa-github-square"></i>
</body>
For me it works but not for the first to the fifth icon because they are pro icons that have to be used with the fontawesome pro account.
<head>
<script src="https://use.fontawesome.com/44c6a45abc.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css" integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<i class="fa-solid fa-user"></i>
<!-- regular style -->
<i class="fa-regular fa-user"></i>
<!-- light style -->
<i class="fa-light fa-user"></i>
<!-- duotone style -->
<i class="fa-duotone fa-user"></i>
<!-- all new thin style -->
<i class="fa-thin fa-user"></i>
<!--brand icon-->
<i class="fa-brands fa-github-square"></i>
</body>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.0.0/css/font-awesome.css">
<style>
i {
font-size : 20px;
padding:0 10px;
}
</style>
<body>
<!-- regular style -->
<i class="fa fa-google-plus"></i>
<!-- light style -->
<i class="fa fa-facebook"></i>
<!-- duotone style -->
<i class="fa fa-user"></i>
<!--brand icon-->
<i class="fa fa-github-square"></i>
</body>

HTML icon duplicated even though written once

I was trying to link a URL to an icon, but it somehow made 4 icons although I only wrote once. This is the part where caused the problem
<head>
<link rel="stylesheet" href="style.css" />
<title>Document</title>
<script src="https://use.fontawesome.com/ca04587938.js"></script>
</head>
<body>
<nav class="navBar">
<div class="logoBox">
<a href="https://www.youtube.com">
<i class="fa fa-youtube-square" />
</a>
<span class="title">Youtube</span>
</div>
<div class="iconBox"></div>
</nav>
</body>
And, this is the result
The icon appears multiple times since you forgot to close your <i> tag.
So instead of:
<i class="fa fa-youtube-square">
write:
<i class="fa fa-youtube-square"></i>

Boostrap 4: How to inline text supposed to be hidden on small screens?

For this particular application, I am trying to hide the text on smaller screen and only show the icon on the left (a comment icon from font awesome):
<a id="newCommentLink" href="#">
<i class="fa fa-comments text-secondary"></i>
<span class="d-none d-md-block">Comment</span>
</a>
As you can see from the above code, what I want is that the text 'comment' to be hidden on mobile screens (xs and sm size) so it only shows up on medium to large size screens. However, this HTML code will display the text 'comment' below the icon, rather than being next to it. I am unable to inline the icon and the text. Anyone knows how to fix this problem, to make the text display inline with the icon?
A few options:
Simply use d-flex on the a
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<a class='d-flex' id="newCommentLink" href="#">
<i class="fa fa-comments text-secondary"></i>
<span class="d-none d-md-block">Comment</span>
</a>
Use d-md-inline-block / d-md-inline-flex instead of d-md-block
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<a id="newCommentLink" href="#">
<i class="fa fa-comments text-secondary"></i>
<span class="d-none d-md-inline-block">Comment</span>
</a>

Fontawesome doesn't work, the icons aren't shown

The problem is that my website aren't shown the Icons. I am a starter and I don't see some error there.
Here is the Code:
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
and here I tried to use icons:
<div class="navigation">
<ul>
<li>
<a href="#">
<span class="icon"><i class="fas fa-home"></i></span>
<span class="title">Home</span>
</a>
</li>
</ul>
</div>
That is not the full code but I think it should display an icon.
The fas variant doesn't exist in that library. Use fa.
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" ntegrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="navigation">
<ul>
<li>
<a href="#">
<span class="icon"><i class="fa fa-home"></i></span>
<span class="title">Home</span>
</a>
</li>
</ul>
</div>

footer font-awesome icon is not respoding on my bluefish coder

I've added a footer to a webprofile. On codepen everything worked, but when I put the same code on bluefish coder, the e-mail icon gets below the facebook and instagram icon.
I would like them to be aligned. One on the side of the other. The three of them. I have not put span or anything like that. I'm putting the specifications below.
p {
display: inline-block;
}
<!-- bootstrap version and the one I know how to work with -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- ======font awesome======= -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<!-- The font awesome icons I put -->
<div class="navbar navbar-inverse navbar-static-bottom">
<div class="container">
<div class="navbar-text pull-left">
<p>© 2017 All Rights Reserved</p>
<p style="font-family: Dancing Script;font-size: 17px;"> Marina Sanchez </p>
</div>
<div class="navbar-text pull-right" style="display: inline-block;">
<i class="fa fa-facebook fa-2x" aria-hidden="true"></i>
<a href="https://www.instagram.com/marina_k25/"><i class="fa fa-instagram fa-2x" aria-hidden="true"></i>
</a>
<a href="mailto:foobar#gmail.com" class="btn btn-lg btn-block btn-social btn-email"><i class="fa fa-envelope-o fa-2x" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
I have finished everything and I'm stuck on this one could anyone help me please.
Also below goes my codepen which the footer is working, but not on my bluefish coder.
https://codepen.io/JT_Cerqueira/full/WZbEdq/
The reason your mail icon is sitting below the other icons is because you have a class on it and it's pulling in as display:block;. To fix this, simply remove this class class="btn btn-lg btn-block btn-social btn-email">. Also, get rid of the unnecessary carrot you have it's parsing it as text and is invalid HTML.
<!-- bootstrap version and the one I know how to work with -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style>
/*=============footer============*/
p {
display: inline-block;
}
</style>
<!-- ======font awesome======= -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<!-- The font awesome icons I put -->
<div class="navbar navbar-inverse navbar-static-bottom">
<div class="container">
<div class="navbar-text pull-left">
<p>© 2017 All Rights Reserved</p>
<p style="font-family: Dancing Script;font-size: 17px;"> Marina Sanchez </p>
</div>
<div class="navbar-text pull-right" style="display: inline-block;">
<i class="fa fa-facebook fa-2x" aria-hidden="true"></i>
<a href="https://www.instagram.com/marina_k25/"><i class="fa fa-instagram fa-2x" aria-hidden="true"></i>
</a>
<a href="mailto:foobar#gmail.com"><i class="fa fa-envelope-o fa-2x" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
<!-- bootstrap version and the one I know how to work with -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style>
/*=============footer============*/
p {
display: inline-block;
}
</style>
<!-- ======font awesome======= -->
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<!-- The font awesome icons I put -->
<div class="navbar navbar-inverse navbar-static-bottom">
<div class="container">
<div class="navbar-text pull-left">
<p>© 2017 All Rights Reserved</p>
<p style="font-family: Dancing Script;font-size: 17px;"> Marina Sanchez </p>
</div>
<div class="navbar-text pull-right" style="display: inline-block;">
<i class="fa fa-facebook fa-2x" aria-hidden="true"></i>
<a href="https://www.instagram.com/marina_k25/"><i class="fa fa-instagram fa-2x" aria-hidden="true"></i>
</a>
<a href="mailto:foobar#gmail.com"><i class="fa fa-envelope-o fa-2x" aria-hidden="true"></i>
</a>
</div>
</div>
</div>
Now you can run code sinppet correct result.