SCSS file is not being applied to my HTML webpage - html

I created a simple network of HTML pages styled with SCSS but the SCSS rules aren't being applied!
Heres how my SCSS file looks like:
//SCSS variables
$Heading-size: 60px;
$Mobile-Heading-size: 40px;
$Mobile-Body-Size: 30px;
$Defualt-background: rgba(149, 149, 243, 0.616);
//SCSS Inheritance and .class selector
.nav{
#extend h1;
}
img{
width: 250px;
}
body {
color: black;
background-color: $Defualt-background;
font-family: Arial, Helvetica, sans-serif;
font-weight: normal;
//SCSS Nesting
h1 {
text-align: center;
size: $Heading-size;
color: tomato;
font-family: Arial, Helvetica, sans-serif;
font-weight: bold;
background-color: $Defualt-background;
}
}
table {
border-radius: 5px;
border-width: 5px;
th {
border-width: 4px;
}
td {
border-width: 2px;
}
}
//responsive #media query
#media only screen and (max-width: 768px){
h1 {
size: $Mobile-Heading-size;
}
body {
//The background is a test to see if it works :)
$Defualt-background: orange;
background-color: $Defualt-background;
size: $Mobile-Body-Size
}
}
And this is how I linked it to my html:
<link rel="stylesheet" href="./CSS/style.css">
Just to be clear im linking the CSS generated by my compiler not the original SCSS!

Related

vs code not working for media query in css

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
<title>Frontend Mentor | QR code component</title>
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
<style>
#media screen (max-width: 300px) {
.body {
background: blue;
}
}
.attribution { font-size: 11px;
text-align: center;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-color: rgb(244, 244, 244);
margin-top: 1%;
margin-left: 30%;
margin-right: 30%;
margin-bottom: 1%;
border-radius: 10px;
width: 300px;
padding: 10px;
padding-right: 20px;
}
.attribution a { color: hsl(228, 45%, 44%); }
body {
background-color: red;
}
.fade {
color: #a9a9b1a7;
font-size: 14px;
}
.QR {
width: 310px;
height: 320px;
border-radius: 10px;
margin:0%
}
</style>
</head>
<body>
<div class="attribution">
<img src="images/image-qr-code.png" alt="img" class="QR">
<h1>Improve your front-end skills by building projects
</h1>
<h2 class="fade">Scan the QR code to visit Frontend Mentor and take your coding skills to the next level
Challenge by Frontend Mentor.
Coded by lalith prasad.</h2>
</div>
</body>
</html>
why my background color is not changing accordingly to the code of media screen.
why my background color is not changing accordingly to the code of the media screen? I used a simple code of media query isn't working. plz, provide a solution for this.
A few things here:
.body should be body
Media query should come after the initial body declaration
Format of media query is #media only screen and
body {
background-color: red;
}
#media only screen and (max-width: 300px) {
body {
background: blue;
}
}
correct form of using media query is:
#media screen and (max-width: 300px) {
and you should change
.body {
background: blue;
}
to
body {
background-color: blue;
}
and because of specificity in css, you should use media query at the last part of style.
So your code should be like this:
<style>
.attribution {
font-size: 11px;
text-align: center;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
background-color: rgb(244, 244, 244);
margin-top: 1%;
margin-left: 30%;
margin-right: 30%;
margin-bottom: 1%;
border-radius: 10px;
width: 300px;
padding: 10px;
padding-right: 20px;
}
.attribution a {
color: hsl(228, 45%, 44%);
}
body {
background-color: red;
}
.fade {
color: #a9a9b1a7;
font-size: 14px;
}
.QR {
width: 310px;
height: 320px;
border-radius: 10px;
margin: 0%
}
#media screen and (max-width: 300px) {
body {
background-color: blue;
}
}
You have a class named attribution and the related div has a width of 300px with some paddings. Therefore, the width of div becomes 300px + {paddingLeft} + {paddingRight} = 330px. Therefore, your screen width cannot be 300px even if you don't have the margins; hence, the media query condition is always false.
Possible solutions to this problem can be:
Leveraging the width or not giving a width to the div that has the attribution class,
Changing the media query condition.

adding multiple background images

ok, so I got an assignment to make a 3 page website using css and html, and we have to use external style sheets, naturally I want to make my stuff look nice, HOWEVER we are only aloud to use our one external sheet, so I was wondering if and or how I would be able to call upon different images to set them as backgrounds, because right now I only have my one background image, and I would like to be able to call upon a different image and set it to the background for each of the 3 pages
-here is my style sheet I can also provide my html page though it is very bear bones and just references stuff from the style sheet, just let me know :)
body {
font-family: Arial, Helvetica, sans-serif;
font: sans-serif;
background-image: url(back1.PNG);
background-attachment: fixed;
background-color: #403f42;
}
h1 {
text-align: center;
color: #0a0068;
padding: 10px;
border-color: #0a0068;
border-style: ridge;
border-width: 10px;
margin: 1in;
background-color: #5184d133;
font-size: 50px;
}
h2 {
text-align: center;
background-color: #59696e71;
padding: 10px;
color: #0a0068;
border-color: #473e93;
border-style: solid;
border-width: 5px;
margin: .25in;
font-size: 40px;
}
h3 {
text-align: center;
color: #007517;
background-color: #62e47c5f;
border-color: rgb(10, 151, 10);
border-style: dashed;
padding: 10px;
border-width: 5px;
font-size: 40px;
margin: 2in;
}
h4 {
text-align: center;
color: #0092b0;
background-color: #62e2ff5f;
border-color: rgb(0, 217, 255);
border-style: double;
padding: 10px;
border-width: 5px;
font-size: 40px;
margin: 2in;
}
h5 {
text-align: center;
color: #580707;
background-color: #5c15155f;
border-color: #580707;
border-style: outset;
padding: 10px;
border-width: 5px;
font-size: 40px;
margin: 2in;
}
a:link {
color: #bf00ff;
}
a:visited {
color: #6d04a652;
}
a:hover {
color: rgb(42, 1, 80);
}
h6 {
font-family: Arial, Helvetica, sans-serif;
font: sans-serif;
background-image: url(armor.png);
background-attachment: fixed;
background-color: #403f42;
}
}
<html>
<link rel="stylesheet" href="style.css">
<head>
</head>
<body>
<h1>
<p>How to beat the ender dragon in Minecraft</p>
</h1>
<h2>
<p>This will be a simple step by step guide for defeating the ender dragon!</p>
<p>and yes, there will be pictures !</p>
</h2>
</body>
<h3>
Finding the End portal
</h3>
<h4>
Gearing Up
</h4>
<h5>
Combat
</h5>
</html>
the website had to use a theme or a tutorial of some kind... that it is why it is a guide on minecraft
I figured it out !
I had to id my bodies
so instead of just having
body in my external file
I needed to have another body in my css file
so in my html I had to do
<body id="body2" class="body2">
and in the css file
body.body2 {
font-family: Arial, Helvetica, sans-serif;
font: sans-serif;
background-image: url(end.PNG);
background-attachment: fixed;
background-color: #403f42;
}
all that it needed was identification,
Something cool you can do is use CSS variables to manage your backgrounds a little easier. It doesn't solve your problem, but it seems like you've got it already.
:root {
--background-1: (bck1.png);
--background-2: (bck2.png);
--background-3: (bck3.png);
}
#body1 {
background: var(--background-1);
}
#body2 {
background: var(--background-2);
}
#body3 {
background: var(--background-3);
}

Same code, Wicked PDF produces two different reports on two different computers

I am using Ruby on Rails to generate a PDF using WickedPDF and emailing it. I have the exact same code on two computers (the code is stored on GitHub and the local instances are up-to-date and exactly the same), but for whatever reason the font being provided within the PDF reports are different. One is Arial, the other appears to be Verdana.
This is the code that's creating the PDF:
header_html = av.render(template: "layouts/report_header", locals: {company_name: company_name, layout: nil)
footer_html = av.render(template: "layouts/report_footer", locals: {company_name: company_name, layout: nil)
pdf_html = av.render(:template => "reports/report", locals: {data: data})
body_pdf = WickedPdf.new.pdf_from_string(
pdf_html,
footer: {
content: footer_html
},
header: {
content: header_html
},
margin: {
top: 25,
bottom: 17,
left: 10,
right: 10
},
)
body_path = Rails.root.join("public/#{#project_id}/body.pdf")
File.open(body_path, "wb") do |file|
file << body_pdf
end
The contents of pdf_html (body of the content) shows this:
<!DOCTYPE html>
<html>
<head>
<style>
p {
color: #545658;
font-size: 12pt;
font-family: "Arial";
font-weight: 500;
}
li {
color: #545658;
font-size: 12pt;
font-family: "Arial";
font-weight: 500;
}
h1 {
color: #ED1C24;
font-weight: normal;
font-family: "Arial";
}
th {
padding-top: 12px;
padding-bottom: 12px;
text-align: center;
background-color: black;
color: white;
}
td {
color: #545658;
padding-top: 5px;
padding-left: 10px;
padding-right: 10px;
padding-bottom: 5px;
}
table.bordered {
border-collapse: collapse;
}
table.bordered td {
border: 1px solid black;
}
table.bordered tr:first-child td {
border-top: 0;
}
table.bordered tr td:first-child {
border-left: 0;
}
table.bordered tr:last-child td {
border-bottom: 0;
}
table.bordered tr td:last-child {
border-right: 0;
}
tr.bordered:nth-child(even) {background-color: #f2f2f2;}
img.finding {
position:absolute;
width:60%;
height: 40px;
margin-left: -20px;
max-width: 100%;
z-index:-1;
}
p.finding {
display: inline;
color: white;
font-weight: bold;
font-size: 16pt;
line-height: 1.75em;
}
pre code {
background-color: #eee;
border: 1px solid #999;
display: block;
padding: 5px;
font-family: "Consolas";
font-size: 10pt;
color: black;
}
</style>
</head>
<body>
<p>Hello world</p>
</body>
</html>
This works just perfectly fine on one computer, but not the other. I have a feeling this issue takes place outside of Rails.
Any suggestions on why this could potentially be giving me different results on two different computers?
wicked_pdf uses wkhtmltopdf. If you want to get the same result on all computers, wkhtmltopdf version must be the same on all computers. Probably the version of wkhtmltopdf on the computers is not the same.
UPDATE
All computers must have Arial fonts. If Arial font is missing, it may cause this error.

How can I place a log in link over this section in the top right corner without shifting the entire content

This is my first html/css project. I tried to use nav and ul tags to put a Log in option on the top right corner over the image. When I do it shifts everything from the middle. I did google before posting but I haven't been successful. I am just wanting to know if I have to float it over or mess with the padding and margins? Here is the html markup`
<!DOCTYPE html>
<html>
<head>
<title>AudioPhile</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<section class="intro">
<div class="inner">
<div class="content">
<h1>Audio<img class="logo" src="https://image.ibb.co/n2A7gb/bar_diagram.png" alt=" folder with white music bars">Phile</h1>
<p>Create. Play. Share music anywhere, on any device with unlimited free storage.</p>
<input class="signup" type="email" id="myEmail" value="Type Your Email Here">
<a class="btn-1" href="#">Get Started</a>
<footer class="credits">© Natalie Pickrom</footer>
</div>
</div>
</section>
</body>
</html>`
The CSS:`#import url('https://fonts.googleapis.com/css?family=Archivo+Narrow|Nunito:200');
html, body {
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
.intro {
height: 100%;
width: 100%;
margin: auto;
background:linear-gradient(0deg,rgba(64,64,64,0.8),rgba(64,64,64,0.8)),url(https://preview.ibb.co/jZbkZw/james_stamler_153487.jpg) no-repeat 95% 95% ;
background-size: cover;
display: table;
top:0;
}
.intro .inner {
display: table-cell;
vertical-align: middle;
width: 100%
max-width: none;
}
.content {
max-width:500px;
margin: 0 auto;
text-align:center;
}
.content h1 {
font-family: "Archivo Narrow", Helvetica, sans-serif ;
color: #F9F3F4;
text-shadow: 0px 0px 300px #000;
font-size: 6em;
padding:0px;
margin:0px;
}
.content p {
font-family: Nunito, "Open Sans", sans-serif;
font-size: 1.253em;
color:#F9F3F4;
Paddding: 0px;
margin-top: 0px;
}
.signup {
border: 0px;
font-family: Nunito, "Open Sans", sans-serif;
letter-spacing: 2px;
color: rgba(128,128,128,0.7) ;
padding: 5px;
width: 67%;
}
.btn-1 {
border-radius:0px;
background-color: #008CBA;
font-family: Nunito, "Open Sans", sans-serif;
color:#F9F3F4;
text-align: center;
text-decoration: none;
text-transform: uppercase;
padding: 3px 10px 4px;
width:50%;
}
.credits {
font-family: Nunito, "Open Sans", sans-serif;
color:#F9F3F4;
text-align: center;
padding: 10px;
}
#media screen and (max-width: 768px) {
.content h1 {
font-size:4em;
}
.btn-1 {
padding: 2px 10px 3px;
width: 25%;
}
p {
font-size: .5em;
}
}
`
Here is the JSfiddle https://jsfiddle.net/1ysegrd6/
Here is what I want to achieve. I want log in where they have home subscribe

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>