How are you doing?
First, thank you for trying to help, I know this question is silly but I couldn't find an answer nor understand why it is not working as expected.
I have the following tree on my machine:
projectFolder
|__ website
|__index.html
For this website, I'm using Bootstrap 4, but I needed to use glyphicons from Bootstrap 3, so I saved the glyphicons part from Bootstrap 3 in a .css file called glyphicons.css. I then uploaded this file to GitHub, which raw version is available here.
When I tried using it in index.html, using the following line to import it, it didn't work.
<link rel="stylesheet" href="https://raw.githubusercontent.com/feRpicoral/GlyphiconsBootstrap4/master/glyphicons.css" type="text/css">
Nevertheless, when I download the file and added it to projectFolder, resulting in the following path, it worked fine, so the problem is not in the .css file.
projectFolder/glyphicons.css
To import the file I was using the same <link> as above but with "../glyphicons.css" as href.
Long story short, when importing a stylesheet hosted on GitHub using the raw link of the file, it does not work.
Am I doing something wrong?
Below you can see the relevant part of the glyphicon.css file and the code that I'm using in index.html. Feel free to run the snippet and understand better what I mean.
#font-face {
font-family: 'Glyphicons Halflings';
src: url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.eot');
src: url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.woff') format('woff'), url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.glyphicon-picture:before {
content: "\e060";
}
<!DOCTYPE html>
<html>
<head>
<!-- Bootstrap4 -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<!-- Glyphicons File -->
<!--<link rel="stylesheet" href="../glyphicons.css" type="text/css"> WORKS (COMMENTED TO USE WITH STACKOVERFLOW SNIPPET)-->
<!-- <link rel="stylesheet" href="https://raw.githubusercontent.com/feRpicoral/GlyphiconsBootstrap4/master/glyphicons.css" type="text/css"> DOESN'T WORK-->
<title>Glyphicons Test</title>
</head>
<body>
<style type="text/css">
div {
font-size: 100px;
margin: 100px auto;
}
#text {
font-size: 20px;
display: block;
}
</style>
<div class="container bg-dark text-center text-white">
<span class="glyphicon glyphicon-picture"></span>
<span id="text">Icon is above if working</span>
</div>
</body>
</html>
Thanks in advance,
Fernando
Taking help from this post - and gitcdn you can create a link which you can refer to in your HTML... i removed the css code where you had loaded the glyphicons and now all glyphicons are loaded from your git link;
div {
font-size: 100px;
margin: 100px auto;
}
#text {
font-size: 20px;
display: block;
}
<!DOCTYPE html>
<html>
<head>
<!-- Bootstrap4 -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="https://gitcdn.link/repo/feRpicoral/GlyphiconsBootstrap4/master/glyphicons.css" />
<title>Glyphicons Test</title>
</head>
<body>
<div class="container bg-dark text-center text-white">
<span class="glyphicon glyphicon-picture"></span>
<span id="text">Icon is above if working</span>
</div>
</body>
</html>
Related
Im a beginner in Visual Studio and my html file/code work fine but my css file doesn't work. My problem is not detected in the workspace.
I also try to do this, nothing happen :
<link href= "CSS\index.css" rel="stylesheet" type="text/css">
CSS code :
style
h1 {
background-color: blue;
}
I am also new but I think I can help. You have two options, that I am aware of.
The first and ideal option would be to reference to a separate style.css file to go along side your maim html page (ex: index.html & style.css).
(index.html)
<!DOCTYPE html>
<html>
<head>
<title>yourwebsite.com</title>
<link rel="stylesheet" type="text/css"
href="style.css">
</head>
<body>
<img src="your.jpg" alt="Handsome Man" width="100"
height="100">
<h1><b>your name</b></h1>
<p>your tag line</p>
<a href="https://twitter.com/yourtwitter"</a>
</body>
</html>
(styles.css)
body{
background-color: #f4f4f4;
color: #555555;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: normal;
/* Same as above */
/* font: normal 12px Arial, Helvetica, sans-serif; */
line-height: 1.6em;
}
h1{
color: #00ff00;
}
p{
color: rgb(0,0,255);
}
The second and worst option is to include your css within your main html file.
(Copied from https://ryanstutorials.net/css-tutorial/css-
including.php)
<!doctype html>
<html>
<head>
<title>Embedded CSS example</title>
<meta name="description" content="A page with embedded css">
<meta name="keywords" content="html css embedded">
<style>
h1 {
text-decoration: underline;
color: #4583c2;
}
p {
padding-left: 20px;
font-size: 18px;
}
</style>
</head>
<body>
...
</body>
</html>
Make sure the index.css file is inside the CSS folder, then add the below link tag.
<link rel="stylesheet" href="./CSS/index.css">
So I'm new to programming and I've been learning on my own through the Odin Project. The first project I've been working on is a recreation of the Google search site. I've got some of the basic HTML layout but my CSS is not being applied, I originally started this project on codepin and everything worked. When I switched to vscode... nothing. Here's what I have so far for HTML and CSS.
.flex-container {
height: 100vh;
border: 3px solid blue;
display: flex;
justify-content: center; /* x-axis */
align-items: center; /* y-axis */
}
.flex-item {
font-size: 90px;
font-family: 'Noto Sans JP', sans-serif;
#G {
color: #4885ed;
}
#o {
color: #db3236;
}
#o1 {
color: #f4c20d;
}
#g {
color: #4885ed;
}
#l {
color: #3cba54;
}
#e {
color: #db3236;
}
.foot {
background-color: #A5A6A1;
height: 2em;
}
.ad {
color: blue;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Google</title>
<style>
#import url('https://fonts.googleapis.com/css2? family=Noto+Sans+JP&display=swap');
</style>
</head>
<body>
<div class ='flex-container'>
<!-- Try using 'span' instead of a div for 'Google'.-->
<div class='flex-item'>
<span id='G'>G</span>
<span id='o'>o</span>
<span id='o1'>o</span>
<span id='g'>g</span>
<span id='l'>l</span>
<span id='e'>e</span>
</div>
<input type="Search">
</div>
<footer class='foot'>
<span id='ad'>Advertising</span>
<span>Business</span>
<span>How search works</span>
</footer>
</body>
</html>
This is my first post so hopefully its a good question. Any and all help is appreciated. Thanks!
You forgot to link your css file to your html file. Add a link tag at the end of the head tag, in case you have the html and css files in the same directory and your css file's name is styles, you can do like this:
<head>
...
<link rel="stylesheet" href="styles.css">
</head>
The reason it works on Codepen is because they do the linking work for you, so the html, js and css file are automatically connected to each other
Looking at CSS code it seems like it is in different file. So in this case you have to link CSS to HTML file you can do this by using <link rel="stylesheet" href="yourfilepath"> inside head tag.
-- You have to call the css file that you made with:
<link rel="stylesheet" href="the file of the css">
The problem:
- Downloaded webfontkit from font squirrel
- added the fonts to a new css file with font family, src, font-weight, font-style
- tried to apply it to my header
- checked my web browser, font changed to a default font but not the custom font I wanted
Things i've tried
- reexamined my code a few times
- downloaded the webfontkit again with other formats .ttf and .svg
index.html file
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags always come first-->
<meta charset="utf-8" />
<meta name= "viewport" content="width=device-width, initial-scale=1" />
<!-- build:css css/main.css -->
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" href="node_modules/bootstrap-social/bootstrap-social.css" />
<link rel="stylesheet" href="css/styles.css" />
<!-- endbuild -->
<title>DEVEDAN: A Digital Marketing Agency</title>
</head>
<body>
<!--I hid the Navbar code because it was irrelevant-->
<!--WEBSITE CONTENT-->
<!-- Page content holder -->
<div class="page-content p-5" id="content">
<!-- Heading -->
<h2 class="display-4 text-white">DEVEDAN</h2>
<p class="lead text-white mb-0">Develop your business w/ Edson & Angelika</p>
<div class="separator"></div>
</div>
<!--I hid the jscode because it was irrelevant-->
</body>
</html>
fonts.css file
#font-face {
font-family: 'siffonOutline';
src: url('fonts/siffonoutline-webfont.eot');
src: url('fonts/siffonoutline-webfont.eot?#iefix') format('embedded-opentype'),
url('fonts/siffonoutline-webfont.woff2') format('woff2'),
url('fonts/siffonoutline-webfont.woff') format('woff'),
url('fonts/siffonoutline-webfont.ttf') format('truetype'),
url('fonts/siffonoutline-webfont.svg#sifonnbasic_outline') format('svg');
font-weight: normal;
font-style: normal;
}
styles.css file
/*Fonts*/
#import "fonts.css";
/*NAVBAR*/
.vertical-nav {
min-width: 17rem;
width: 17rem;
height: 100vh;
position: fixed;
top: 0;
left: 0;
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.1);
transition: all 0.4s;
}
.page-content {
width: calc(100% - 17rem);
margin-left: 17rem;
transition: all 0.4s;
}
/*WEBSITE CONTENT*/
h2 {
font-family: 'siffonOutline';
}
body {
background: #599fd9;
background: -webkit-linear-gradient(to right, #599fd9, #c2e59c);
background: linear-gradient(to right, #599fd9, #c2e59c);
min-height: 100vh;
overflow-x: hidden;
}
.separator {
margin: 3rem 0;
border-bottom: 1px dashed #fff;
}
Click link to view the output of my code: https://i.stack.imgur.com/ePLCh.png]
check #import path is rite or wrong
#import "fonts.css";
I'm trying to upload the Montserrat font from google fonts on a website I'm building and for some reason it's not happening. I've read a separate Q&A on here that suggests it may be an issue with chrome?
I want Montserrat specifically because it's the closest google font likeness to Gotham.
This is how I have it loaded on my file -
style.css
#import url(https://fonts.googleapis.com/css?family=Montserrat:400,500,80);
body{
font-family: 'Montserrat', sans-serif;
}
I tried it also in my <head> section in index.html underneath the bootstrap link -
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,800" rel="stylesheet">
I don't know whether it's an issue with bootstrap not wanting to override or a separate issue. Any assistance appreciated.
Follow the below code.
<!DOCTYPE html>
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,500,800" rel="stylesheet">
<style>
body {
font-family: 'Montserrat', sans-serif;
}
</style>
<body>
<h1>Montserrat</h1>
</body>
I had a similar issue and this is how I solved it.
First import the "Montserrat" font to the "bootstrap.css"
#import url('https://fonts.googleapis.com/css?family=Montserrat:400,600,700&display=swap');
then replace the font-family with Montserrat;
body {
margin: 0;
font-family: Montserrat;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="style.css" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<meta charset="UTF-8">
<title>Test</title>
</head>
<body>
<div id="wrapper">
<div id="sidebar-wrapper">
<div class="sidebar-nav">
<ul>
<li>This is some test text</li>
</ul>
</div>
</div>
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</body>
</html>
That is my html
html, body {
width: 100%;
height: 100%;
}
#sidebar-wrapper {
position: absolute;
width: 200px;
height: 100%;
background-color: black;
}
.sidebar-nav ul li a {
display: block;
color: white;
font-family: "Open Sans", serif;
font-size: 20px;
}
That's my css
Applying the Open Sans font family to the a element changes the font but it looks bold, when it should be thinner.
I've tried other fonts as well and they all look bolder.
How it should be:
How it is (Here it looks more bubbly):
Update: https://jsfiddle.net/xzw2ssz5/
Try to paste the following code in your custom CSS file.
body {
font-family: "Open Sans" !important;
}
And make sure that your fonts are properly being loaded by navigating to the Network tab in developer tools and then selecting the checking the fonts.
If you don't want to apply the fonts on the entire document then try putting !important in front of your font-family rule like so:
.sidebar-nav ul li a {
display: block;
color: white;
font-family: "Open Sans", serif !important;
font-size: 20px;
}
Let me know if that works for you.
Update
okay, I've got it up and running. Basically, you haven't selected any font-weight from the google fonts library. Replace your <link> with this one:
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i" rel="stylesheet">
Keep the font-weights values which you want and remove all others. That's why you were not able to change its font-weight. Hope that helps now.
Hi I think the problem is the order you're calling the your css resources
move the Open Sans import on top of your css stylesheet try this or just #import the css font directly into your stylesheet.
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
<link rel="stylesheet" href="style.css"
type="text/css">