Showing posts with label CSS. Show all posts
Showing posts with label CSS. Show all posts

Monday, September 29, 2014

Placing Glyphicons on Bootstrap Navbar

Bootstrap Navbar's appearance may be improved by adding Glyphicons on its items. Just place a <span> with classes .glyphicon and glyphicon-icon-name, e.g. glyphicon-home besides each navbar item

The navbar with icons next to each item as it appears on my laptop:


The same navbar is it initially appears in its collapsed state on my mobile is shown below:


The navbar on my mobile is now expanded. Icons appear beside each navbar item.


The codes in this posted were lifted from the samples in the tutorial links:
The  final code in its entirety is as follows:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Example of Twitter Bootstrap 3 Responsive Navbar with Icons</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<style type="text/css">
 .navbar{
  margin-top: 20px;
 }
</style>
</head> 
<body>
<div class="container">
    <nav role="navigation" class="navbar navbar-inverse">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" data-target="#navbarCollapse" data-toggle="collapse" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a href="#" class="navbar-brand">Brand</a>
        </div>
        <!-- Collection of nav links, forms, and other content for toggling -->
        <div id="navbarCollapse" class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
    <!--icons are added on this navbar for improved appearance-->
                <li class="active"><a href="#"><span class="glyphicon glyphicon-home"></span> Home</a></li>
                <li><a href="#"><span class="glyphicon glyphicon-user"></span> Profile</a></li>
                <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="glyphicon glyphicon-paperclip"></span> Messages <b class="caret"></b></a>
                    <ul role="menu" class="dropdown-menu">
                        <li><a href="#">Inbox</a></li>
                        <li><a href="#">Drafts</a></li>
                        <li><a href="#">Sent Items</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Trash</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </nav>
</div>
</body>
</html>

Need help on some web coding task? Let me know about it. Email me at jrwxpun.dolor@gmqoapmssail.co57agsblm and I'll be more than happy to blog about it with my thoughts.

Hosting of the sample pages were provided for by the following:

Sunday, September 21, 2014

Text Transparency on Bootstrap Carousel Background

Taking one step further on my previous post, we now display text with transparency effect on Bootstrap carousel.

The carousel in its original format can be viewed on http://getbootstrap.com/examples/carousel/

The URL below demonstrates text transparency on Bootstrap carousel background on my portfolio website:
http://jundolor.eu5.org/bootstrapsamples/carousel01/

Feel free to download the files. The carousel as it appears on my laptop is shown below:

The carousel as it appears on my mobile is shown below:

Like the previous post, we remove or comment out the <img> tags before div class .container within the carousel. The <p> tags surrounding the buttons are replaced with <div> tags. In a while, css transparency on <p> and <h> tags will be applied. The buttons are to display with no transparency.
    <div class="carousel-inner">
        <div class="item">
          <!--<img src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="First slide">-->
          <div class="container">
            <div class="carousel-caption">
     <h1>Example headline.</h1>
     <p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p>
     <div><a class="btn btn-lg btn-primary" href="http://getbootstrap.com/examples/carousel/#" role="button">Sign up today</a></div>
            </div>
          </div>
        </div>
        <div class="item active">
          <!--<img src="data:image/gif;base64,R0lGODlhAQABAIAAAGZmZgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Second slide">-->
          <div class="container">
            <div class="carousel-caption">
              <h1>Another example headline.</h1>
     <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
     <div><a class="btn btn-lg btn-primary" href="http://getbootstrap.com/examples/carousel/#" role="button">Learn more</a></div>
            </div>
          </div>
        </div>
        <div class="item">
          <!--<img src="data:image/gif;base64,R0lGODlhAQABAIAAAFVVVQAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Third slide">-->
          <div class="container">
            <div class="carousel-caption">
              <h1>One more for good measure.</h1>
     <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
     <div><a class="btn btn-lg btn-primary" href="http://getbootstrap.com/examples/carousel/#" role="button">Browse gallery</a></div>
            </div>
          </div>
        </div>
      </div>

The next step is to prepare the image for the carousel background. The fountain photo was taken during our visit to Fort Santiago :-)

The carousel comes with a stylesheet, carousel.css. Add the styles below. The <p> and <h> tags in the carousel are given a transparency effect. The fountain image is set as the background image. Originally, the text in the carousel have light color- a style declaration for class .carousel-caption converts color to black. Make changes as needed to adopt to your style and taste.
.carousel .carousel-inner {
/*Note url should point to where the image is relative to the css*/
background: url('../images/fountain.png') no-repeat center center;
background-color:#fff;

}
.carousel .carousel-inner .item .container .carousel-caption{
color:black;
}
.carousel .carousel-inner .item .container .carousel-caption h1, .carousel .carousel-inner .item .container .carousel-caption  p{
 background-color:#fff;
 opacity: 0.7;
 border: 2px solid;
    border-radius: 5px;
}

That should now display the carousel text with transparent effect while keeeping a background image.

Need help on some web coding task? Let me know about it. Email me at jrwxpun.dolor@gmqoapmssail.co57agsblm and I'll be more than happy to blog about it with my thoughts.

Wednesday, September 17, 2014

Applying Banner Background on Bootstrap Carousel

Banners may be placed in the background within Bootstrap carousel by applying some adjustments in the CSS. A screen shot of the carousel banner is shown below:











The template for the carousel can be downloaded from http://getbootstrap.com/examples/carousel/ comes with a carousel.css file. This is where the CSS will be adjusted.

I've designed a very simple banner that will go with the slide- a Nippon rising sun on black background, blackrisingsun.png:









The CSS for the background banner will position horizontally and vertically. Take note that we are designing for mobile devices as well. The design of the banner may be considered for this. Since the left and right sides will be clipped out, perhaps its a good idea to put emphasis on the center of the background.

The set of codes that display the carousel is as follows:
<div class="carousel-inner">
        <div class="item">
          <img src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="First slide"><!---->
          <div class="container">
            <div class="carousel-caption">
     <h1>Example headline.</h1>
     <p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p>
     <p><a class="btn btn-lg btn-primary" href="http://getbootstrap.com/examples/carousel/#" role="button">Sign up today</a></p>
            </div>
          </div>
        </div>
        <div class="item active">
          <img src="data:image/gif;base64,R0lGODlhAQABAIAAAGZmZgAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Second slide">
          <div class="container">
            <div class="carousel-caption">
              <h1>Another example headline.</h1>
     <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
     <p><a class="btn btn-lg btn-primary" href="http://getbootstrap.com/examples/carousel/#" role="button">Learn more</a></p>
            </div>
          </div>
        </div>
        <div class="item">
          <img src="data:image/gif;base64,R0lGODlhAQABAIAAAFVVVQAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Third slide">
          <div class="container">
            <div class="carousel-caption">
              <h1>One more for good measure.</h1>
     <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
     <p><a class="btn btn-lg btn-primary" href="http://getbootstrap.com/examples/carousel/#" role="button">Browse gallery</a></p>
            </div>
          </div>
        </div>
      </div>

Notice the <img> tags before the div class .container- this displays the background of each slide. This may either be removed or commented out:

Next, on carousel.css, add the style below. The background URL should point to the image.
.carousel .carousel-inner {
background: url('images/blackrisingsun.png') no-repeat center center;
background-color:#777;
}

This should now display the carousel with the background:











Need help on some web coding task? Let me know about it. Email me at jrwxpun.dolor@gmqoapmssail.co57agsblm and I'll be more than happy to blog about it with my thoughts.

Monday, September 15, 2014

Placing Thumbnails on Bootstrap Carousel

The sample Bootstrap I've come across on http://getbootstrap.com/examples/carousel/ provides a template for creating a running banner slide at the top of the page:











To add a thumbnail to each slide, minor tweaks will be done to the code.The class. carousel-caption inside the class .carousel-inner contains codes that display content on the running banner.



The initial step is to create a thumbnails to display. For this post, let's have three 100x100 images: red.png, green.png and blue.png.

To apply the first thumbnail, look for the first occurence of the class .carousel-caption. Add the class .media as shown below:






Next, add the image tag right above the first paragraph. Take note of the style applied:


This now displays the image on the slide as shown below:


Now, apply the steps while replacing the image on the remaining classes .carousel-caption:


Each slide in the carousel will now have the thumbnails:

Need help on some web coding task? Let me know about it. Email me at jrwxpun.dolor@gmqoapmssail.co57agsblm and I'll be more than happy to blog about it with my thoughts.

Saturday, August 30, 2014

Hiding emails posted on websites from spambots

At the end of my last post, I've posted my email for you to send your web development/ coding questions and inquiries:





The nice thing about it? You can see it but spambots can't! That means that the email address posted won't be flooded with pesky spams or other what-have-you.

So how did I do it? I simply applied the steps discussed in http://www.websitecodetutorials.com/code/javascript/graceful-degradation-mailto-email-address-obfuscation-tutorial.php to show my email at the browser and hide it from the spambots at the same time.

Now, let's go over the steps to apply for an anonymous email, john.doe@nowhere.com

First, we decide that the email link will be <a href="mailto:john.doe@nowhere.com">email me</a>. On the link http://www.wmtips.com/tools/html-obfuscator/, do the following:

  1. Copy/ paste <a href="mailto:john.doe@nowhere.com">email me</a> on the input box provided
  2. Click Get obfuscated code button
  3. The resulting code is displayed. Select the code and copy. You may click Select All link.
  4. View the generated code


Enter the CSS below on the web page where the email link will appear:

<style>
#method1 b {
display:none;
}

Going back to the generated obfuscated code, copy/paste it on the bottom end of web page. This may be placed right before the </body> tag.

Next, we put in the HTML for the email link. From the CSS, we see that anything placed inside the <b> tag within any element tag of ID 'method1' will not be displayed at all. Therefore, we can write HTML with such tags to confuse spambots crawling our website.

The HTML, <p><span id="method1">joh<b>r</b>ndoe@g<b>wma</b>mail.com</span></p>, will only be seen by Spambot as it is, but will output on browser as:
The obfuscated code will show the email link below the email address:





The full HTML

<html>
  <head>
    <title>Hiding Email from Spambots</title>
 <style>
  #method1 b {
  display:none;
  }
 </style>
  </head>
  <body>
  <p><span id="method1">joh<b>r</b>ndoe@no<b>wma</b>where.com</span></p>
  <script type="text/javascript">
 <!--
 var s="=b!isfg>#nbjmup;kpio/epfAopxifsf/dpn#?fnbjm!nf=0b?";
 m=""; for (i=0; i<s.length; i++) m+=String.fromCharCode(s.charCodeAt(i)-1); document.write(m);
 //-->
 </script>
 <noscript>
 You must enable JavaScript to see this text.
 </noscript>
  </body>
</html>
Got web development stuffs you want me to help you out? Email it to me at junrahsy.dolor@gwmamail.com and I'll be more than happy to blog about it with my inputs.