Gyancode

A free library of HTML, CSS, JS

Search This Blog

Friday 31 March 2017

CSS Font Sizes

In this tip, you will learn how to specify a font’s size with CSS.

Being a practical nerd, I will not waste time talking about all the various methods for declaring font sizes with CSS … instead I will concentrate on the two widely used ways and then briefly explain the differences. First, the two main methods:

By pixel

By em

What is the difference between and EM and a pixel?

Pixels are an absolute measure of a font’s size and an EM is a relative measure – that means the actual pixel size of the font (as they appear on screen) set with EM’s, can fluctuate. This makes using EM’s trickier. So the nerd answer is NOT to use EMs!

Let’s look at a quick EM example anyway:

<div style="font-size:1.2em">
So the above would cause the fonts to be about 20% larger than the baseline font size – thus 1.2em. I am not going to go into all the nerd details about EM’s because I think pixels are the way to go.

Thursday 30 March 2017

Height:100vh doesn't work correctly with content in the div

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>Height:100vh doesn't work correctly with content in the div</title>
</head>
<style type="text/css">
    .intro { color: #fff;height: 100vh; background: url('yourimage.jpg') no-repeat center center; background-size: cover;  position: absolute;bottom: 2em; }
    p.hello {margin: 30px; }
    .page1 {color: #fff; height: 100vh; background: beige; }
    .page2 {color: #fff; height: 100vh; background: black; }
</style>

<body>
    <div class="container">
        <div class="row">

            <div id="intro" class="intro">

                <div class="text-center">
                    <p class="hello">
                        Intro text is coming soon!
                    </p>
                    <div class="col small-col-12 intro--buttons">
                        <p>
                            Buttons coming here.
                        </p>
                    </div>
                </div>

            </div>

            <div id="page1" class="col col-12 page1">
                <p>Tekst test</p>
            </div>

            <div id="page2" class="col col-12 page2">
                <p>Tekst test.</p>
            </div>

        </div>
    </div>
</body>
</html>

Wednesday 29 March 2017

Height for Full Screen Div?

I have a DIV element that needs to fill the entire screen until the user scrolls and reveals the content. So essentially remain at the viewports height.

Here is what I did and it works, but it’s only compatible with newer browsers.

.section-full {
height:100vh;
min-height:100vh;

}

Tuesday 28 March 2017

Changing the Font to All Caps with CSS

While text in general is hard to read when written in all caps – and considered the electronic version of yelling – using CAPS for emphasize is a handy tool.

Headers are a place where capitalization is frequently used. And to assure that your header is displayed uniformly throughout the site without having to worry about actually writing in all caps, just use CSS:

h1 {
text-transform: uppercase;
}


With this, everything that has the h1 tag applied, WILL APPEAR IN ALL CAPS.

Another interesting text-transformation property is "capitalize"

h1 {text-transform: capitalize;}


With This, All Your Words Will Begin With A Capital Letter!

The 3 ways to insert CSS into your web pages



1. With an external file that you link to in your web page:

<link href="myCSSfile.css" rel="stylesheet" type="text/css">
or using the import method:

<style type="text/css" media="all">
   @import "myCSSfile.css";
</style>

 

2. By creating a CSS block in the web page itself; typically inserted at the top of the web page in between the <head> and </head> tags:

<head>
   <style type="text/css">
      p { padding-bottom: 12px; }
   </style>
</head>


3. By inserting the CSS code right on the tag itself:

<p style="padding-bottom:12px;">Your Text</p>

Wednesday 22 March 2017

How can i add label in Select Option in HTML

You can use this html code in your webpage.


<select class="board-selector">
                <option label="Create a Board">Create a Board</option>
                <option label="View all Boards">View all Boards</option>
                <optgroup label="Recent Boards">
                    <option label="awesome" selected="selected">awesome</option>
                </optgroup>
            </select>

Friday 17 March 2017

Box rotate with css transforms

<div class="original">
  <div class="spin">
    <figure class="box box-1">Box 1</figure>
  </div>
</div>

<div class="original">
  <div class="spin">
    <figure class="box box-2">Box 2</figure>
  </div>
</div>

<style>
body {
  color: #fff;
  font: 600 14px/24px "Open Sans", "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", Sans-Serif;
  margin: 12px 15px;
}
.original,
.box {
  border-radius: 6px;
}
.original {
  background: #eaeaed;
  border: 1px dashed #cecfd5;
  float: left;
  margin: 12px 15px;
}
.box {
  background: #2db34a;
  height: 95px;
  line-height: 95px;
  text-align: center;
  width: 95px;
}
.spin {
  cursor: pointer;
  transform-style: preserve-3d;
}
.spin:hover {
    animation: spin 5s linear infinite;
}
@keyframes spin {
  0% {
    transform: rotateY(0deg);
  }
  100% {
    transform: rotateY(360deg);
  }
}
.box-1 {
  transform: rotate(20deg);
}
.box-2 {
  transform: rotate(-55deg);
}

</style>

Why can't I use background image and color together?

If you tring to do is to show both color & image you can use this css body tag


body{ width: 100%; height: 100%;  margin: 0; background: url(../images/bg_new.png) #f6f6f6 repeat right top !important; }

Tuesday 14 March 2017

Print Jquery

If you want print your page 
use this script in web page...


<script type="text/javascript">
window.print();
</script>


Sunday 12 March 2017

Fixed header and footer

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Fixed header and footer</title>
<style type="text/css">
html, body { margin:0; padding:0; font-family: verdana; font-size: 13px;}
html, body {  height:100%;}
#top-bar {position:fixed; top:0px;left:0px;height:50px;width:100%; z-index:999; overflow:hidden;}
#topbar-inner, #footer-inner { background: #03bf95; text-align: center; color: #FFF;font-size: 18px; padding: 9px;}
#footer { position:fixed; bottom:0; width:100%; height:40px; z-index:999;}
.inner { padding:50px 0; position:relative;}
p {  margin:0 0 1em; font-size: 13px;}
#contain-all { width: 60%; margin: 0px auto; padding: 20px;}
</style>
</head>
<body>
<div id="outer">
  <div id="contain-all">
    <div class="inner">
      <p>This is an experimental layout and untested in a real situation but preliminary
        results look good. <strong>Note</strong> that opera 10.6 has introduced a bug where if the page has been scrolled and then refresh is clicked the fixed elements will disappear. </p>
      <p>The header and footer need to be a fixed height and are therefore not suited to large amounts of fluid content.</p>
      <p>Good browsers get normal fixed positioning but ie6 and under make use of a bug in ie6 where children of elements that have overflow defined behave as though they are fixed.</p>
      <p>some text to wrap : some text to wrap : some text to cause scrolling :
        : some text to wrap : some text to wrap : some text to cause scrolling :
        : some text to wrap : some text to wrap : some text to cause scrolling :
        : some text to wrap : some text to wrap : some text to cause scrolling :
        : some text to wrap : some text to wrap : some text to cause scrolling :
        : some text to wrap : some text to wrap : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>some text to cause scrolling : </p>
      <p>Last bit of text</p>
    </div>
  </div>
</div>
<div id="top-bar">
  <div id="topbar-inner">Fixed Top & bottom</div>
</div>
<div id="footer">
  <div id="footer-inner"> Fixed footer </div>
</div>
</body>
</html>