Jump to content

Recommended Posts

Hello everyone.

I've for some time thought about how it was possible to make a webpage fadeinto a background color, when
the page has been visited. If i for example refresh this page, it should not start with a light background,
until i visit the page in a new tab.

I have a example here:
http://olivercooper.me/

 

Notice the fading effect, only occurs once. ( even if you refresh its still not fading from white-dark )

 

 

I've heard that this requires JQuery, or JavaScript, to make it fade, when the site is visited.

 

Do you have any ideas how this might be possible?

 

And just to ask stupid: Does anyone know what that "Hello" font is?

 

 

Best regards,

 

~Mikk809h 

 

 

Edit: Why did this post just get multiplied? I only posted this once? Can anyone please remove the others? Thanks in advance

Edited by mikk809h
Link to comment
https://forums.phpfreaks.com/topic/289267-fadein-onload-of-website/
Share on other sites

If i for example refresh this page, it should not start with a light background,

until i visit the page in a new tab.

 

I'm not following. Are you talking about the default white background that EVERY page starts with until the page loads and styles can be applied? At least, that is all I see when I refresh that page. If so, there's nothing you can do about that. When you click refresh, the browser starts "from scratch". Every page starts loading with a white background. Although that is a feature of the browsers not anything to do with the code to build the pages. It may be something that can be changed in the browser, but it would be a change by the individual users, not something that could be controlled in the code for the page. Well, it *may* be possible to prevent the refresh at all, but I can't see anything good coming from that.

 

If you don't want that momentary flash of white when loading a new page (i.e. clicking a link), then you could implement AJAX to change the content dynamically without a page refresh. But, if the user explicitly clicks refresh it will start over.

 

 

 

Does anyone know what that "Hello" font is?

Yes, I do. It's right there in the source code.

Edited by Psycho

Okay, Thanks for your answer, I found the font and got it onto my web.
Now i have a weird transition problem, which makes the text disappear after a 2s transition.
 

html {
  height: 100%;
}

body, html{
  padding: 0;
  margin: 0;
  font-family: Comfortaa, Verdana, Arial, sans-serif;
  min-height: 100%;
  transition: background-color 1s, color 1s; /* This works fine and smoothly! */
  background: #1a1a1a;
  color: white;
  min-height: 380px;
}

.container {
  opacity: 0;
  -webkit-transition: opacity 2s; /* This seems to make the image first appear, then it "looks" like the opacity is getting lower, so its invisible */
  transition: opacity 2s;
}

.first {
  font-size: 200px;
  line-height: 200px;
  margin-top: -100px;
  position: absolute;
  text-align: center;
  width: 100%;
  opacity: 1; /*This should make the text fully visible... */
  top: 35%;
}

And here's some pics:

 

When i go to the page (no refresh)
JyDBRR9.png
Starts from the picture above, and fading into:

YmiKScU.png

Then The text is being "faded out"

into this:

6CyMvPH.png

Into:

tNmEkTq.pnginto:

bkYJ1bG.png

 

 

 

 

 

Hmm.. Is this a cause of my Css style code?

You say you have a weird transition problem and then post some pics. So, I have an idea of what IS happening. But, I have no idea what you are wanting to happen. Are you wanting to stop after the 2nd image (i.e. not have the text transition to black)? The transition would be controlled by JS, yet you've not provided that code.

I would suggest the following:

 

Set the default style of the text as black and make its display property 'none'. So, it won't be in the initial page load at all.

 

Then, perform the background transition to black. Once that completes, change the display property of the text to in-line and perform the transition to white

Well.. Somehow it doesnt fade in that text. i think its because im placing the display: none; wrong...

 

@font-face {
  font-family: Comfortaa;
  src: url('Fonts/Comfortaa/Comfortaa-Regular.ttf');
  font-weight: normal;
}

@font-face {
  font-family: Comfortaa;
  src: url('Fonts/Comfortaa/Comfortaa-Light.ttf');
  font-weight: 300;
}

@font-face {
  font-family: Comfortaa;
  src: url('Fonts/Comfortaa/Comfortaa-Bold.ttf');
  font-weight: bold;
}

html {
  height: 100%;
}

body, html{
  z-index: 10;
  padding: 0;
  margin: 0;
  font-family: Comfortaa, Verdana, Arial, sans-serif;
  min-height: 100%;
  transition: background-color 1s;
  background: #1a1a1a;
  color: #1a1a1a;
  min-height: 380px;
}

.container {
  -webkit-transition: color 2s, display 2s;
  transition: color 2s, display 2s;
  display: inline;
}

.first {
  color: white;
  font-size: 200px;
  line-height: 200px;
  margin-top: -100px;
  position: absolute;
  text-align: center;
  width: 100%;
  top: 35%;
}

.second {
  color: white;
  font-size: 30px;
  line-height: 200px;
  margin-top: -100px;
  position: absolute;
  text-align: center;
  width: 100%;
  top: 50%;
}

.third {
  color: white;
  font-size: 30px;
  line-height: 200px;
  margin-top: -100px;
  position: absolute;
  text-align: center;
  width: 100%;
  top: 55%;
}
index.php

 


<html>
  <head>
  <title>
    MikkOS
  </title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <link rel="stylesheet" type="text/css" href="style.css">
  </head>
  <body>
    <!--<div id="background">-->
      <!--<script type="text/javascript">
        $(window).ready(function() {
        $('#background').fadeIn(1024);
        });
      </script>-->
      <!--<div class="HeadText">-->
      <div class="container">
          <div class="first">
            Hello
          </div>
          <div class="second">
            Mikkel Andersen
          </div>
          <div class="third">
            Odense, Denmark
          </div>
      </div>
      <!--</div>-->
    <!--</div>-->
  </body>
</html>

Thanks in Advance

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.