0

I have been racking my brain for the past hour trying to get my HTML file to display what I'm adding. This is an example of my code :

@import url('https://fonts.googleapis.com/css2?family=Fredoka&family=Rubik:wght@300&display=swap');

html {
    height: 100%;
}

body {
    margin: 0;
}


/* Header that contains logo, horizontal navigation, and lists. */
.container {
    width: 80%;
    height: 200px;
    margin: 0;
}

header {
    font-family: 'Rubik', sans-serif;
    font-weight: 300;
    background-color: rgb(31,150,196);
    background-image: linear-gradient(160deg, rgba(31,150,196,1) 0%, rgba(52,165,175,1) 50%, rgba(173,225,230,1) 100%);
}

header::after {
    content: '';
    display: table;
    clear: both;
}

.logo {
    float: left;
    padding: 50px 15px 30px 150px;
    width: 550px;
    height: 200px;
}

nav {
    float: left;
    
}

nav ul {
    margin: 0;
    padding: 70px 15px 15px 15px;
    list-style: none;
    font-weight: 500;
    font-size: 25px;
}

nav li {
    display: inline-block;
    margin-left: 70px;
    padding-top: 30px;

    position: relative;
}

nav a {
    color: #ffffff;
    text-decoration: none;
    text-transform: uppercase;
}

nav a::before {
    content: '';
    display: block;
    height: 5px;
    width: 100%;
    background-color: #ffffff;

    position: absolute;
    top: 0;
    width: 0;

    transition: all ease-in-out 200ms;
}

nav a:hover::before {
    width: 100%;
}
/* Header that contains logo, horizontal navigation, and lists. End. */

/* Sidebar. */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    list-style: none;
    text-decoration: none;
    font-family: 'Rubik', sans-serif;
}

.wrapper {
    display: flex;
    position: relative;
}

.wrapper .sidebar {
    position: fixed;
    width: 200px;
    height: 100%;
    background: #b9b9b9;
    padding : 35px 0;
}

.wrapper .sidebar h2 {
    color: #ffffff;
    text-transform: uppercase;
    text-align: center;
    margin-bottom: 30px;
    font-size: 35px;
}

.wrapper .sidebar ul li {
    padding: 25px;
}

.wrapper .sidebar ul li a {
    color: #1A5276;
    display: block;
    font-size: 20px;
}
<!DOCTYPE html>
<html lang="en">
<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">
    <link rel="stylesheet" href="style.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Fredoka&family=Rubik:wght@500&display=swap" rel="stylesheet">
    <title>BigPay - Banking Made Easier</title>
    <script src="https://kit.fontawesome.com/4b00a26c1e.js" crossorigin="anonymous"></script>
</head>

<body>
    <header>
        <div class="container">
            <img src="pics/bigpay-logo.png" alt="company-logo" class="logo" />
                <nav class="navbar">
                    <ul>
                        <li><a href="#">HOME</a></li> 
                        <li><a href="#">ANALYTICS</a></li>
                        <li><a href="#">PAYMENTS</a></li>
                        <li><a href="#">CARD</a></li>
                        <li><a href="#">SETTINGS</a></li>
                    </ul>
                </nav>

        </div>
    </header>

    <div class="wrapper">
       <div class="sidebar">
           <h2>Menu</h2>
            <ul>
                <li><a href="#"><i class="fa-solid fa-magnifying-glass"></i> Search</a></li>
                <li><a href="#"><i class="fa-solid fa-calendar"></i> Date</a></li>
                <li><a href="#"><i class="fa-solid fa-book"></i> Category</a></li>
                <li><a href="#"><i class="fa-solid fa-money-bill"></i> Amount</a></li>
                <li><a href="#"><i class="fa-solid fa-globe"></i> Country</a></li>
                <li><a href="#"><i class="fa-solid fa-filter"></i> Type</a></li>
            </ul>
       </div>
    </div>

    <h1>Hello</h1>

</body>
</html>

The problem arises when I'm adding more content to the page in the HTML file, specifically the h1 tag that has Hello inside it. Even when I had Live Server turned on on my VSCode, it still will not update anything to the browser. I have tried closing and opening the browser twice, I even closed my VSCode and opened it again but it still will not update anything. I have restarted my computer, I tried to open the html on Internet Explorer and it's still not updating the h1 tag that I added. Before turning off my computer I have saved the code but it was fine, just a normal save. Plus, I even tried to make a new html with just the word hello wrapped in a h1 tag, that worked. But not my previous code.

Before you guys ask, I have looked through the questions of the same problem on here but nothing really applies to my problem. I have never had this happened before and I do not want to restart writing my code. The reason I added the CSS in here also is because I cannot, for the life of me, figure out what went wrong.

I went through this question :

Why is my HTML file not displaying to the browser?

and the answers have not helped.

Any replies will be greatly appreciated and I thank you very much for taking the time to help me out on this matter.

  • Did you clear your cache? And why on earth would you use Internet Explorer? – j08691 Feb 28 '22 at 20:25
  • I was testing them both on Chrome and IE, but they are not displaying anything. I have cleared my cache and restarted my PC afterwards but nothing is still displaying. – Laila June Feb 28 '22 at 20:28
  • Does this help? => [How do we control web page caching, across all browsers?](https://stackoverflow.com/questions/49547/how-do-we-control-web-page-caching-across-all-browsers) – daddygames Feb 28 '22 at 20:28
  • Sorry, it has not helped. – Laila June Feb 28 '22 at 20:35
  • Did you try just turning off caching in the browser? Edge/Chrome has a switch for it in their DevTools... https://i.stack.imgur.com/mbRHl.png – Heretic Monkey Feb 28 '22 at 20:36
  • Does the browser's debugger console show any errors? – daddygames Feb 28 '22 at 20:40
  • Done that, but the h1 tag with Hello wrapped in it still has not shown up. What am I doing wrong? I'm legit having a breakdown. T_T – Laila June Feb 28 '22 at 20:40
  • What are you seeing when you inspect the elements in your browsers dev tools? Is the h1 there but just underneath something else? – A Haworth Feb 28 '22 at 20:45
  • The h1 is hidden underneath the sidebar which has fixed position. Give it a transparent background and you’ll see the Hello. Your problem has nothing to do with version control or caching. – A Haworth Feb 28 '22 at 20:47
  • Yeah, I just notice that when using the developer tools, it's hidden beneath the sidebar. I will try do that now. – Laila June Feb 28 '22 at 20:52
  • That somehow worked, but if I didn't move the text to the center, the text will not appear. But why was it hidden behind the sidebar anyways? What was in my code that made this happened? Before posting on here, I did try to include a section tag, but it was the same. – Laila June Feb 28 '22 at 20:58
  • You have position fixed for sidebar. This means it is taken out of the flow. – A Haworth Feb 28 '22 at 22:05

2 Answers2

0

A small trick you can do to the HTML is this:

<link rel="stylesheet" href="style.css?ver=1">

then increment ver each time you do a change.

That way you are tricking the browser to believe there is a new version of the file.

Trond
  • 363
  • 1
  • 4
  • 14
  • Thank you for your answer but unfortunately it has not helped. I might need to delete everything and start from scratch again. – Laila June Feb 28 '22 at 20:36
0

Are you sure the text isn't just blending with the background? Can you find h1 in the dev tools?

What happens if you put it in the div.container?

You can also try CTRL + F5 to do a hard refresh of the page in the browser.

EDIT:

Found it. Your .wrapper.sidebar is fixed and is covering the h1. You need to make another div to account for this, or come up with a different solution. Here is one example:

HTML

<div class='foundIt'>
  <h1>Hello</h1>
</div>

CSS

.foundIt {
  margin-left: 200px;
}

.foundIt's margin-left accounts for the .wrapper.sidebar width size. Hope this helps!

Ian C.
  • 78
  • 7
  • It appeared, actually. At the center and very top of the page. – Laila June Feb 28 '22 at 20:59
  • And yes, it blended with the background, but I don't know why it does that?? – Laila June Feb 28 '22 at 21:00
  • Oops, I updated the wrong answer at first. Still a noob at stack overflow I guess :P – Ian C. Feb 28 '22 at 21:06
  • @LailaJune See if the above helps – Ian C. Feb 28 '22 at 21:06
  • that worked. But if I wanna keep my sidebar untouched, I will still need to figure out another method, like you suggested. Damn... that was a grueling 2 hours. :') Thank you very much for all your help. – Laila June Feb 28 '22 at 21:16
  • Welcome! To be clear, my answer doesn't affect the sidebar. It just uses margin to move div.foundIt 200px away from the left of the page. Anything less than 200px will currently be hidden by the wrapper since its a 'fixed' position. – Ian C. Feb 28 '22 at 21:21
  • It's okay, I might need to just get rid of the sidebar and come up with a better solution. Perhaps a retracting one. I'll figue it out. ☺️ – Laila June Feb 28 '22 at 21:32