#font-face sometimes works sometimes and not other times? - html

I am having an issue with #font-face rule in my css.
In some stylesheets it works perfectly in others it doesn't work at all...
As you can see in the snippet I use an external file for my font but in this particular case it is not working...
Any thoughts anyone?
Endless gratitude will be your share :)
#charset "utf-8"
#font-face {
font-family: sinhala;
src: url(fonts/Sinhala.ttc);
}
#wrapperportfolio4 {
width: 45%;
float:left;
position:relative;
margin-left: 5%;
margin-top: -42.5%;
box-shadow: 3px 5px 4px 0px black;
height: 20vw;
}
#wrapper4trans {
width: 45%;
float:left;
position:relative;
margin-left: 5%;
margin-top: -42.5%;
background-color: black;
opacity: 0.5;
height: 20vw;
}
#box1title {
width: 65%;
font-family: sinhala;
font-size: 1.0vw;
color: white;
margin-top: 2%;
text-align: center;
}
#box1img {
width: 60%;
position:relative;
float:left;
margin-left: 2.5%;
margin-top: 1.5%;
}
#box1txt{
width: 25%;
position:relative;
float:left;
font-family: sinhala;
font-size: 1.0vw;
color: white;
margin-left: 5%;
margin-top: 5%;
text-shadow: 0px 2px 4px rgba(0,0,0,0.50);
}
#box1txt2{
width: 25%;
position:relative;
float:left;
font-family: sinhala;
font-size: 1.0vw;
color: white;
margin-left: 5%;
margin-top: 5%;
text-shadow: 0px 2px 4px rgba(0,0,0,0.50);
}
#box1link {
width: 25%;
position:relative;
float:left;
font-family: sinhala;
font-size: 1.0vw;
color: white;
margin-left: 5%;
margin-top: 5%;
text-shadow: 0px 2px 4px rgba(0,0,0,0.50);
cursor: pointer;
}
<div id="wrapperportfolio4">
<p id="box1title">www.pieterswebdesign.com</p>
<img id="box1img" src="images/box1img.png" />
<p id="box1txt">Pieter's Web Design is een beginnende webdesigner gevestigd in Gent.</p>
<p id="box1txt2">Voor betaalbare professionele websites is dit de ideale oplossing.</p>
<a id="box1link" href="https://www.pieterswebdesign.com">www.pieterswebdesign.com</a>
</div>

Chances are it's the font, as you really need to create a webfont kit and use various font file types:
For example:
#font-face {
font-family: 'FontName';
src: url('fontname-webfont.eot');
src: url('fontname-webfont.eot?#iefix') format('embedded-opentype'),
url('fontname-webfont.woff2') format('woff2'),
url('fontname-webfont.woff') format('woff'),
url('fontname-webfont.ttf') format('truetype'),
url('fontname-webfont.svg') format('svg');
}
You should use a webfont generator like:
https://www.fontsquirrel.com/tools/webfont-generator
(obviously you need to have a licence to use some fonts as webfonts so best to check this before converting any.)

for browsers compatibility you have to use this rule.
/* Fonts */
#font-face {
font-family: 'sinhala';
src: url("./fonts/sinhala.eot");
src: url("./fonts/sinhala.eot?#iefix") format('embedded-opentype'),
url("./fonts/sinhala.woff") format('woff'),
url("./fonts/sinhala.ttf") format('truetype'),
url("./fonts/sinhala.svg#montezregular") format('svg');
font-weight: normal;
font-style: normal;
}
You have to get three formats (woff, eot, ttf) of the FONT.
See the https://www.fontsquirrel.com/tools/webfont-generator
On this page you can converit the font to correcto format.
Succes!

Related

I add font but they doesn't work (css) #font_face

.writing {
display: block;
margin-top: auto;
margin-bottom: auto;
text-shadow: 5px 5px red, 10px 10px green, 15px 15px yellow;
font-family: Niconne;
text-align: center;
font-size: 150;
}
#font-face {
font-family: "Niconne";
src: url("../fonts/Niconne-Regular.ttf") format("truetype");
/* src: url("../fonts/Niconne-Regular.woff") format("woff");
src: url("../fonts/niconne-v10-latin-regular.woff2") format("woff2");
src: url("../fonts/niconne-v10-latin-regular.eot") format("EOT"); */
}
these are my codes. it works fine now but when i put out other sources it turns back to the first point ( it doesn't work). i want to use it locally ( don't give me fontlink)
You have to add quotes to your font-family, so it will be like this font-family: "Niconne"
Updated Answer:
#font-face {
font-family: "Niconne";
src: url("../fonts/Niconne-Regular.ttf") format("truetype");
src: url("../fonts/Niconne-Regular.ttf") format("truetype"),
url("../fonts/Niconne-Regular.woff") format("woff"),
url("../fonts/niconne-v10-latin-regular.woff2") format("woff2"),
url("../fonts/niconne-v10-latin-regular.eot") format("EOT");
}
Change font-family: Niconne; to font-family: "Niconne";
.writing {
display: block;
margin-top: auto;
margin-bottom: auto;
text-shadow: 5px 5px red, 10px 10px green, 15px 15px yellow;
font-family: "Niconne"; /* **Change Here** */
text-align: center;
font-size: 150;
}

#font-face not loading in shadowDom

this.shadowRoot.innerHTML = `
<style>
#font-face {
font-family: SpaceGrotesk;
src: url(/fonts/SpaceGrotesk-Medium.ttf);
}
#font-face {
font-family: SpaceGroteskLight;
src: url(/fonts/SpaceGrotesk-Light.ttf);
}
* {
box-sizing: border-box;
}
.tipme {
position: relative;
font-size: 1.4rem;
font-family: SpaceGrotesk, sans-serif;
text-align: center;
background-color: #fff;
padding: 4rem 1.4rem 1.4rem;
box-shadow: 0px 4px 40px rgba(0, 0, 0, 0.08);
margin: 5rem 1.4rem 1.4rem;
width: 50rem;
}
h1 {
font-family: SpaceGroteskLight, sans-serif;
font-weight: 400;
font-size: 2.6rem;
margin: 1rem;
}
`;
...
The browser is not requesting the the font files.
I tried in incognito mode so its not a cache issue.
This is a distributed component running on multiple sites, so I cannot just load the font in the parent html. It needs to be encapsulated.
I ended up just dynamically adding style loading fonts to parent page:
this.fonts = `
#font-face {
font-family: SpaceGrotesk;
src: url(${this.host}/fonts/SpaceGrotesk-Medium.ttf);
}
#font-face {
font-family: SpaceGroteskLight;
src: url(${this.host}/fonts/SpaceGrotesk-Light.ttf);
}
`;
const style = document.querySelector('style[data-description="tipme-fonts"]');
if (!style) {
const el = document.createElement('style');
el.dataset.description = 'tipme-fonts';
el.appendChild(document.createTextNode(this.fonts));
document.head.appendChild(el);
}

cant use fonts in fonts directory

I have inserted the fonts but I can't see them. I don't know why there is no space in between the words.
<html>
<head>
<link href="app.css" rel="stylesheet" />
</head>
<body>
<header>
<div class="container">
<div id="topbar">
</div>
<nav id="main">
<img src="logo.svg" alt="logo">
<ul id="main-menu">
<li>Η ΟΜΟΣΠΟΝΔΙΑ</a></li>
<li>ΑΡΚΑΔΩΝ ΕΡΓΑ</a></li>
<li>ΕΠΩΝΥΜΟΙ ΑΡΚΑΔΕΣ</a></li>
<li>ΝΕΑ - ΕΝΗΜΕΡΩΣΗ</a></li>
<li>ΕΠΙΣΚΕΨΗ ΣΤΗΝ ΑΡΚΑΔΙΑ</a></li>
<li>ΑΝΑΖΗΤΗΣΕΙΣ ΣΤΗΝ ΑΡΚΑΔΙΑ</a></li>
</ul>
</nav>
</div>
</header>
</body>
</html>
#font-face {
font-family:Proxima Nova ;
src: url(./fonts/Proxima\ Nova\ Regular.otf);
font-weight: normal;
}
#font-face {
font-family:Proxima Nova ;
src: url(./fonts/Proxima\ Nova\ Bold.otf);
font-weight: bold;
}
#font-face {
font-family: SourceSansPro ;
src: url(./fonts/SourceSansPro-Regular.ttf);
font-weight: normal;
}
#font-face {
font-family: SourceSansPro ;
src: url(./fonts/SourceSansPro-Bold.ttf);
font-weight: bold;
}
body {
margin: 0;
font-family: 'SourceSansPro-Regular', serif;
}
header {
background: url('./images/bg.png') bottom center no-repeat;
background-size: cover;
height: 750px;
}
#topbar {
height: 70px;
text-align: center;
}
nav#main {
background-color:white;
border-radius: 4px;
height: 60px;
position: relative;
}
#logo{
position: absolute;
display: block;
border: 10px solid #AB0427;
border-radius: 100%;
left: 50px;
top: 50%;
transform: translateY(-50%);
}
#logo img{
display: block;
}
.container{
width: 1360;
margin: 0 auto;
}
#main-menu{
margin: 0;
padding: 0 20px 0 320px;
display: flex;
align-items: center;
justify-content: space-between;
height: 60px;
list-style: none;
}
#main-menu a {
color:#002868 ;
font size: 14px;
font-weight: bold;
}
Try Using Formats and make sure the path is correct
Note: Remove the spaces if there are no spaces is in the filename, change the backward slash into forwarding slash
#font-face {
font-family:"Proxima Nova" ;
src: url(./fonts/Proxima/Nova/Regular.otf) format("opentype");
font-weight: normal;
}
#font-face {
font-family:"Proxima Nova";
src: url(./fonts/Proxima/Nova/Bold.otf) format("opentype");
font-weight: bold;
}
#font-face {
font-family: "SourceSansPro";
src: url(./fonts/SourceSansPro-Regular.ttf) format("truetype");
font-weight: normal;
}
#font-face {
font-family: "SourceSansPro";
src: url(./fonts/SourceSansPro-Bold.ttf) format("truetype");
font-weight: bold;
}
Looks like you have backslashes in the urls of the top two. I'd check to make sure the filepath is correct, that may be part of the problem.
Additionally, you could try to add a format property like so:
#font-face {
font-family: Proxima Nova ;
src: url(./fonts/Proxima/Nova/Regular.otf) format("open-type");
font-weight: normal;

How do i make this responsive so it changes in size?

So now this objects, when i resize the browser they jump down underneath eachother but i want it to just change size to fit a phone resolution. Can anyone help me to make this work, becuase i have been trying by making width have an max and so on but it seems that it dosen´t work for some reason. Down below i have uploaded an image of how it looks when the objects jump down.
#box h2 {
font-family: 'Open Sans', sans-serif;
font-size: 26px;
color: #888;
margin-bottom: 10px;
font-weight: 700;
text-align: left;
text-transform: uppercase;
text-decoration: none;
}
.text-1 {
max-width: 900px;
margin-right: 130px;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
color: #888;
text-align: left;
}
.text-1 p {
margin-top: 30px;
font-size: 22px;
line-height: 36px;
text-align: left;
}
#box {
background-color: white;
display: inline-block;
}
.first {
width: 300;
margin-top: 5px;
max-height: 200px;
box-shadow: 2px;
float: left;
margin: 30px;
}
.second {
width: 300px;
margin-top: 5px;
max-height: 200px;
box-shadow: 2px;
float: left;
margin: 30px;
}
.third {
width: 300px;
margin-top: 5px;
max-height: 200px;
box-shadow: 2px;
float: left;
margin: 30px;
}
.third p {
font-family: 'Open Sans', sans-serif;
font-size: 18px;
line-height: 32px;
color: #888;
font-weight: 300;
}
.first p {
font-family: 'Open Sans', sans-serif;
font-size: 18px;
line-height: 32px;
color: #888;
font-weight: 300;
}
.second p {
font-family: 'Open Sans', sans-serif;
font-size: 18px;
line-height: 32px;
color: #888;
font-weight: 300;
}
h3 {
font-size: 26px;
font-weight: 700;
color: #888;
line-height: 30px;
text-transform: uppercase;
}
.parallax {
/* The image used */
background-image: url('/assets/image/parallax.jpg');
/* Full height */
height: 250px;
/* Create the parallax scrolling effect */
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
<div id="box">
<h2>Vår process</h2>
<div class="text-1">
<p>VI HJÄLPER DIG MED ALLT.</p>
</div>
<div class="first wow fadeInLeft"><img src="assets/image/kontakt.png">
<h3>KONTAKT</H3>
<p>Kontakta oss genom telefon eller vårat kontaktformulär på hemsidan.</p>
</div>
<div class="second wow fadeInUp"><img src="assets/image/arende.png">
<H3>GRANSKAN</H3>
<P>Vi går igenom ditt ärende och ser om vi har möjlighet och utföra jobbet.</P>
</div>
<div class="third wow fadeInRight"><img src="assets/image/leverans.png">
<H3>LEVERANS</H3>
<P>Vi kommer hem till dig och fixar det du behöver hjälp med.</P>
</div>
</div>
You should try HTML "figure" for this.
Link -> jsfiddle.net/DamianToczek/kxfu7Lep/6/
Fix this Stackoverflow:
(Links to jsfiddle.net must be accompanied by code. Please indent all code by 4 spaces using the code toolbar button or the CTRL+K keyboard shortcut. For more editing help, click the [?] toolbar icon.)
Tried with backticks, with ctrl + K and it keeps saying the same.
To resize elements depending on screen size use #media queries. Here is a good resource.
#media screen and (max-width: 1440px) {
.signmodal {padding-top: 15%;}
#signformclosebutton {font-size: 2em;}
.imgmodal{padding-top: 5%;}
.imgcontainer{width: 52.5%;}
};

Any way to make the border nearer to the body content ? (HTML/CSS) Pictures provided

What I have done so far : http://goo.gl/sDhLA
What I am supposed to achieve : http://goo.gl/tqo7m
Thanks in advance for any help, newbie in html/css here.
Cheers.
UPDATE
My bad. I forgotten to mention that I am actually aiming for the results with the least amount of major edits to the code, as there are some code which I can't change. ( stipulated in my assignment ) .
On the other hand, there isn't any harm in learning more stuff though. Learnt more about new commands like line-height, box-sizing: border-box is really interesting.
However, I was quite sad that negative padding doesn't occur. It would have solved the gap at the left and right edges eh ? :O
Looks like you need to reduce the width for your container (or increase the width of your content).
You should post your code here though, only then I will be able to be sure this answer is correct.
Your code is a mess. Here's what I made (I have the units in cm because it will gives better control when printing, you may change the units)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Revisions Bookstore and Cafe</title>
<style type="text/css">
#font-face {
font-family: 'ChunkFiveRegular';
src: url('Chunkfive-webfont.eot');
src: local('?'), url('Chunkfive-webfont.woff') format('woff'), url('Chunkfive-webfont.ttf') format('truetype'), url('Chunkfive-webfont.svg#webfontb5K2fJwj') format('svg');
font-weight: normal;
font-style: normal;
}
* {
padding: 0;
margin: 0;
}
h1 {
border: 0.1cm solid rgb(65, 105, 225);
font-family: ChunkFiveRegular,serif;
background-color: rgb(189, 204, 212);
font-size: 2em;
}
#card div {
font-family: ChunkFiveRegular,serif;
}
#card {
font-family: Verdana,serif;
width: 15cm;
padding: 0.2cm;
border: 0.07cm black solid;
margin: 1cm auto;
}
#card div p {
padding: 0.2cm 0.2cm 0.2cm 0.4cm;
}
#card > p {
background: black;
color: white;
text-align: right;
padding: 0.1cm;
}
</style>
</head>
<body>
<div id="card">
<h1>Revisions Bookstore and Cafe</h1>
<div>
<p class="maintext">Custom brewed coffee and hand-selected books.</p>
<p class="maintext">Special orders are our specialty.</p>
</div>
<p>412 N. 25th St.<br/>Richmond, VA 23223<br/>(804) 555-2565</p>
</div>
</body>
</html>
​
I updated your jsfiddle: http://jsfiddle.net/BramVanroy/LGFLB/1/
A hint: do NOT use an ID 'body' (or any html tag as ID for that matter)! It gets confusing! You can easily target the body by simply using body.
I have kept the HTML structure you proposed. I changed quite a lot of the CSS. Especially the width, margins and size. Also note box-sizing!
body {
font-family: Verdana;
border: 0.07cm solid black;
margin: 2.5em;
margin-left: 17em;
margin-right: 4em;
width: 45em;
}
h1 {
text-align: center;
border: 0.1em solid rgb(65,105,225);
width: 96%;
margin: 0.2em auto;
padding: 0.25em;
font-family: Rockwell;
font-weight: bold;
letter-spacing: 2px;
background-color: rgb(189,204,212);
font-weight: normal;
font-size: 2.5em;
box-sizing: border-box;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
}
#contact {
text-align: right;
width: 96%;
margin: 1em auto 0;
padding: 0.25em;
font-family: Rockwell;
color: white;
background-color: #212100;
margin-bottom: 8px;
}
#box {
width: 92%;
margin: 0 auto;
padding: 0.5em;
line-height: 2;
}
.maintext {
text-align: left;
}
​
Well I looked at achieving the result you are wanting so i've basically manually set things to the same width as your original but with a couple of modifications (mainly just setting margins and widths) while keeping things in em format.
but heres the new css:
#font-face {
font-family: 'ChunkFiveRegular';
src: url('Chunkfive-webfont.eot');
src: local('?'), url('Chunkfive-webfont.woff')format('woff'),url('Chunkfivewebfont.ttf') format('truetype'), url('Chunkfive-webfont.svg#webfontb5K2fJwj')format('svg');
font-weight: normal;
font-style: normal;
}
h1 {
text-align: center;
border: 0.1em solid rgb(65,105,225);
margin-top: 8px;
margin-left:8px;
margin-right:8px;
padding: 0.25em;
font-family: ChunkFiveRegular;
background-color: rgb(189,204,212);
font-weight: normal;
font-size: 2em;
}
#contact {
text-align: right;
margin: 0 8px 8px;
padding: 1em;
font-family: ChunkFiveRegular;
color: white;
background-color: #212100;
margin-bottom: 8px;
}
#box {
margin: 0 8px;
padding: 0.5em;
}
.maintext {
text-align: left;
}
#body {
font-family: Verdana;
border: 0.07cm solid black;
margin: 2.5em;
margin-left: 23em;
margin-right: 4em;
width: 33.4em;
}
</style>