© Aravind Shenoy 2020
A. ShenoyLearning Bulmahttps://doi.org/10.1007/978-1-4842-5482-0_3

3. Layout CSS Helpers

Aravind Shenoy1 
(1)
Mumbai, Maharashtra, India
 

In modern layouts, texts are not placed in an ad-hoc way compared to the archaic ways used in old, legacy web sites. Containers are an awesome control for placing and grouping text, images, graphics, headings, buttons, and glyphicons in a single group.

It is quite handy, as you can resize, move, adjust, modify, or place the entire container group instead of moving each individual element inside it. Containers, levels, media objects, banners, tiles, cards, boxes, and panels are the various containers in Bulma that help enclose different types of content within it.

In this chapter, we will look at these Bulma containers, which are quite useful in modern layouts in this digital era. Let’s get started right away.

Containers and Levels

In Bulma, the container control centers the content horizontally. In addition, Bulma’s container element is responsive and brings out a certain consistency across different devices, specifically tailored for mobile platforms.

In Listing 3-1, we will learn how to use the container element. However, we will first define the columns grid container and then create a separate container control, to show the difference between the grid columns container and the separate container control.
<div class="columns">
  <div class="is-mobile is-centered" style="border:5px solid OliveDrab;">
        <div class="column is-full"  style="background-color: Wheat;">
        <p>
        cat ipsum dolor sit amet...
        </p>
        </div>
  </div>
  </div>
  <br> <br> <br>
  <div class="section" style="border:5px solid OliveDrab;">
    <div class="container" style="background-color: Wheat;">
     <p>
        cat ipsum dolor sit amet, ....
      </p>
    </div>
  </div>
Listing 3-1

Grid Container vs. Standalone Container Element

In Listing 3-1, we define the columns grid, which is centered. We use the is-full class for the columns so that it occupies all 12 columns of the grid. We assign a border and wheat color to it.

Then we create an independent container element using the container class. We assign a border and wheat color to it just like we did for the columns container.

The output of the code is shown in Figure 3-1.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig1_HTML.jpg
Figure 3-1

Grid column full width vs. normal container

As you can see in Figure 3-1, the output varies. The initial output container is the 12-grid columns container, while the container below is designed with the container class. You can see the space and padding around the content, which results in a different output compared with the 12-column full-width grid layout.

Even the container element in Bulma comes in regular, full width, and widescreen sizes. For a full HD screen, all you need to do is add the is-fullhd class to the container class. In Listing 3-2, we have just added the is-fullhd class to the container class from the previous code Listing 3-1.
<div class="is-mobile is-centered" style="border:5px solid OliveDrab;">
         <div class="column is-full"  style="background-color: Wheat;">
         <p> cat ipsum dolor... </p>
         </div>
  </div>
  </div>
  <br> <br> <br>
  <body>
  <div class="section" style="border:5px solid OliveDrab;">
    <div class="container is-fullhd" style="background-color: Wheat;">
     <p>   cat ipsum dolor....      </p>
    </div>
  </div>
Listing 3-2

Grid Column Full Width vs. Full HD Container

The output of the code is seen in Figure 3-2.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig2_HTML.jpg
Figure 3-2

Grid column full width vs. full HD container

The full HD container is wider; therefore, the content is stretched to the right and left occupying more space due to the is-fullhd class.

To see the difference between a normal container and a full HD container more clearly, let’s see the code in Listing 3-3.
<div class="section" style="border:3px solid OliveDrab;">
    <div class="container" style="background-color: Wheat;">
     <p>
        cat ipsum dolor...
      </p>
    </div>
         </div>
         <br>
         <div class="section" style="border:3px solid OliveDrab;">
    <div class="container is-fullhd" style="background-color: Wheat;">
     <p>
        cat ipsum dolor...
      </p>
    </div>
         </div>
         <br>
    </div>
Listing 3-3

Normal Standalone Container vs. Full HD Container Component

The output of the code is seen in Figure 3-3.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig3_HTML.jpg
Figure 3-3

Normal container control vs. full HD container

In Figure 3-3, you can see the normal container element followed by that of the full HD container element. You can now clearly see the difference between the normal and full HD container, as the content occupies more space to the right and left of the viewport for the full HD element (remember that the content is the same for both these containers).

Bulma also has a levels container, which can be used for most of the web site’s elements. The difference between levels and container control is that the elements within the levels control are centered vertically by default.

Let’s look at the code for the levels container in Listing 3-4.
<div class="section" style="border:3px solid YellowGreen;">
    <div class="container">
             <nav class="level">
             <div class="level-left">
                   <p class="level-item"><a class="button is-primary"><strong> Bulma Mail</strong></a></p>
                   <p class="level-item"><a class="button is-info"><strong>Compose</strong></a></p>
                   <p class="level-item"><a class="button is-info"><strong>Delete</strong></a></p>
                   <p class="level-item"><a class="button is-success"><strong>Send</strong></a></p>
               </div>
               <div class="level-item has-text-centered">
                   <img src="Images/MATRIX-OF-SHREK.png" alt="MATRIX-OF-SHREK" style="height: 175px;">
               </div>
               <div class="level-right">
                   <div class="level-item">
                     <div class="field has-addons">
                         <p class="control">
                           <input class="input" type="text" placeholder="Enter Search Item">
                         </p>
                         <p class="control">
                           <button class="button">
                               <strong>Search</strong>
                           </button>
                         </p>
                     </div>
                   </div>
               </div>
              </nav>
      </div>
  </div>
Listing 3-4

Levels Container Element

In Listing 3-4, we used the container element for an element. Inside the column of the container, we created a <nav> tag to which we assigned the level class. Moving forward, we create a <div> element to which we assign the level-left class. This will align the element to the left of the container. We create four paragraph <p> elements with the level-item class. We include links within each <p> tag and design button for each link using the button class. We use different contextual colors for each of the four buttons: primary, link, info, and success.

Next, we create another <div> element and assign a level-item class to it and include the has-text-centered class. This will align the content in the center of the levels container. We also include an image inside this <div> element, which is also centered.

Further, we create the third <div> element and assign the level-right class to it. Then we define a level-item class for a <div> element inside the third <div>element. We create a search box. Initially, for creating the search box we define a <div> and assign the field class to it. Then we create a paragraph element <p> and assign the control class to it. We then use the input class with the type as text and include a placeholder. Next, we create the Search button. For this we add the has-addons class to the field class, using which we had created the search box. Now we create a button element below the <p> tag and assign the same control class to it. Then we name the button as Search.

The output of the code is shown in Figure 3-4.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig4_HTML.jpg
Figure 3-4

Levels container

As you can see, the level-left class has pulled the content to the left, whereas the level-right class has pushed the content to the right of the levels container.

Media Objects

Social media web sites usually have text next to several graphical formats such as images, icons, infographics, or videos. Media objects help you in designing this structure, wherein data or information is placed alongside graphical content in a hassle-free, uncomplicated manner. This UI component is quite handy in repetitive design like blog posts, comments, tweets, etc.

Bulma’s media objects can be better understood by the following code:
<article class="media">
  <figure class="media-left">
   <img src="Images/Shrek.png" alt="Shrek-In-Matrix" style="height: 93px;">
  </figure>
  <div class="media-content">
    <div class="content">
      <p>
        <strong>Shrek</strong>
        <br>
         Havana brown. Malkin...
        <br>
        <small><a><strong>Love it :- <span class="icon is-small"><i class="fas fa-heart"></i></span></strong>
        </a> ········ <a> <strong>Reply all :-<span class="icon is-small"><i class="fas fa-reply"></i></span></strong></a> ········  <strong>3 days</strong> </small>
      </p>
    </div>
</article>
Listing 3-5

Media Object with Image and Content

In Listing 3-5, we defined a main <article> tag to which we assign a media class. Then, we use the <figure> tag to which we assign the media-left class and insert an image source using the <img> tag. After the media is defined, we create a <div> element within the main <article> tag below the <figure> tag and assign the media-content class to it. Then we create another element inside it, assign the content class, and enter the sample prose. Once the sample prose has been entered, we define the three icons below it using the Bulma supported icon tags (we will get to icons in later chapters). See Figure 3-5.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig5_HTML.jpg
Figure 3-5

Main media object with the image and the content

Moving forward, we will nest a text area below this media object as seen in Listing 3-6.
<article class="media">
              <div class="media-content">
                   <div class="field">
                     <p class="control">
                           <textarea class="textarea" placeholder="What are you thinking....post here"></textarea>
                     </p>
                   </div>
                   <div class="field">
                     <p class="control">
                           <button class="button is-success">Submit comment</button>
                     </p>
                   </div>
               </div>
             </article>
             <br>
      </article>
Listing 3-6

Adding a Text Area Box

In Listing 3-6, we nest a text area akin to the one seen in a form. This text area will be nested inside the main <article> tag used at the first line of code in Listing 3-5. For designing the text area, again we use an <article> tag (think child article), and assign the media class to it. Since there is no image in the text area code, we directly use a <div> element and assign the media-content class to it. Then we create a paragraph element and assign the control class to it. We define a text area element with the textarea class. Below the textarea element, we define another <div> and assign the field class to it. Next we define a paragraph tag and assign the same control class to it as the one used in the text area code. Then we create a button using the button element and assign the is-success contextual color to it (the color is similar to spring green and is a built-in contextual color.

The output of the code so far is seen in Figure 3-6.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig6_HTML.jpg
Figure 3-6

Text area below the main media object

Following this, we nest a media object below the text area, as seen in Listing 3-7.
<article class="media">
                <figure class="media-left">
   <img src="Images/Oracle.png" alt="Oracle" style="height: 93px;">
  </figure>
               <div class="media-content">
                   <div class="content">
                     <p>
                         <strong> ORACLE </strong>
                         <br>
                         Malkin scottish fold....
                         <br>
                         <small><a><strong>Love it :- <span class="icon is-small"><i class="fas fa-heart"></i></span></strong>
             </a> ········  <a> <strong>Reply all :- <span class="icon is-small"><i class="fas fa-reply"></i></span></strong></a> ········  <strong> 1 day</strong> </small>
                     </p>
                   </div>
               </div>
             </article>
Listing 3-7

Nested Media Object Below the Parent Media Object

In Listing 3-7, we define a nested <article> element. We assign the media class to it. Then we use a <figure> tag to which we assign the media-left class. Next we insert an image using the <img> tag. Then we define a <div> to which we assign the media-content class. Next, we define a <div> element within the preceding <div> element and assign the content class to it. The code is same as the one when we created the first media object except that this is a nested article tag and the sample image and content are different.

The output of the code so far is shown in Figure 3-7.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig7_HTML.jpg
Figure 3-7

Nested media object under the text area

Then we create another media object in a similar manner. The code for the next media object is shown in Listing 3-8.
<article class="media">
                <figure class="media-left">
   <img src="Images/Oracle.png" alt="Oracle" style="height: 93px;">
  </figure>
               <div class="media-content">
                   <div class="content">
                     <p>
                         <strong> ORACLE </strong>
                         <br>
                         Malkin scottish fold. Singapura abyssinian kitty and manx balinese . Tiger manx so norwegian forest but british shorthair. Mouser xega
                         <br>
                         <small><a><strong>Love it :- <span class="icon is-small"><i class="fas fa-heart"></i></span></strong>
             </a> ········  <a> <strong>Reply all :- <span class="icon is-small"><i class="fas fa-reply"></i></span></strong></a> <strong> 1 day</strong> </small>
                     </p>
                   </div>
               </div>
             </article>
Listing 3-8

Adding the Other Nested Media Object

The output of the entire code is shown in Figure 3-8.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig8_HTML.jpg
Figure 3-8

Entire media object code output

Banners

The Hero banner is a UI component in Bulma used to highlight the site’s most essential content. Hero banners draw user attention, making it useful from a saleable aspect in modern web site layouts, akin to traditional banners and posters in traditional advertising.

In line with the “pictures speak louder than words” viewpoint, Hero banners help in products/solutions promotion on web sites. Bulma’s Hero banners help add images and aesthetical content, well suited for those web layouts where there is usually minimal data, prevalent in single page design.

To understand banners really well, let’s see an example in Listing 3-9.
<section class="hero">
  <div class="hero-body">
    <div class="container">
      <h1 class="title">
        Banner Main Title
      </h1>
      <h2 class="subtitle">
        Banner Subtitle
      </h2>
    </div>
  </div>
</section>
Listing 3-9

Basic Hero Banner

In Listing 3-9, we have used a section tag and assigned a hero class to it. The <div> within the <section> tag has been assigned the hero-body class. We create another <div> with the container class and then define the title and subtitle for the Hero banner.

The output of the code is shown in Figure 3-9.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig9_HTML.jpg
Figure 3-9

Basic Hero banner

We can add contextual colors to the banner. We need to add the specific contextual color class to the <section> tag to which the hero class is assigned. Let’s see an example where we have assigned the contextual color success (a shade of green) to it.
<section class="hero is-success">
  <div class="hero-body">
    <div class="container">
      <h1 class="title">
        Banner Main Title
      </h1>
      <h2 class="subtitle">
        Banner Subtitle
      </h2>
    </div>
  </div>
</section>
Listing 3-10

Creating a Hero Banner with a Contextual Color

The output of the code is shown in Figure 3-10.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig10_HTML.jpg
Figure 3-10

Success contextual color for the Hero banner

You can establish a gradient feel to any color by adding the is-bold class in conjunction with the color class of the banner. You can also define difference sizes for the banner by using the respective medium, large, and fullheight classes. Let’s see an example in Listing 3-11, where we have used the gradient bold class and the fullheight class alongside the hero class.
<section class="hero is-bold is-success is-fullheight">
  <div class="hero-body">
    <div class="container">
      <h1 class="title">
        Banner Main Title
      </h1>
      <h2 class="subtitle">
        Banner Subtitle
      </h2>
    </div>
  </div>
</section>
Listing 3-11

Adding a Gradient to Contextual Color Alongside the Fullheight Attribute

The output of this code is shown in Figure 3-11.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig11_HTML.jpg
Figure 3-11

Hero banner with the success color gradient and fullheight size

In a full-height Hero banner, we can define the navigation in the top section by using the hero-head class. Then we can define the banner body by using the hero-body class. Finally, we can design the footer of the Hero banner using the hero-foot class.

Let’s understand it by means of the example in Listing 3-12.
<section class="hero is-bold is-primary is-fullheight">
 <!-- Banner Top -->
 <br>
 <div class="hero-head">
    <div class="container">
        <nav class="breadcrumb is-centered">
  <ul>
    <li><a href="#" class="has-text-white">Home</a></li>
    <li><a href="#" class="has-text-white">About</a></li>
    <li><a href="#" class="has-text-white">Portfolio</a></li>
      <li><a href="#" class="has-text-white">Services</a></li>
    <li><a href="#" class="has-text-white">Blogs</a></li>
  </ul>
</nav>
    </div>
      </div>
  <!-- Banner Body -->
  <div class="hero-body">
    <div class="container">
      <h1 class="title has-text-centered">
        Shrek Solutions
      </h1>
      <h2 class="subtitle has-text-centered">
        Web Matrix Architecture
      </h2>
    </div>
  </div>
  </nav>
  </div>
</section>
Listing 3-12

Hero Head and Body Code

In Listing 3-12, we have defined the code for the Hero head and Hero body sections. Initially, we use the code for creating a full-height banner. We assign the hero, is-bold, is-primary, and is-fullheight classes to the <section> tag. The banner therefore is a full-height hero banner with a gradient color shade of the primary contextual color.

Then we define the enclosed <div> with the hero-head class. Within this we include another <div> element and assign the container class to it, to create a container-based padded layout. Then we use a <nav> navigation element and assign the breadcrumb class to create a navigation breadcrumb. We further use the is-centered class to the <nav> element so that the breadcrumb is positioned at the center in the hero-head section.

Moving forward, we create an unordered list using the <ul> tag and the <li> tags within the <ul> tags. Once we have defined the name of the navigation options, we move on to the body section of the banner.

In the banner body section, we create a separate <div> element and assign the hero-body class to it. We define a container for the body section using the container class for the enclosed <div> element. We define the headings using the title and subtitle classes. Once we code the names of the headings, we move on to executing this part of the code.

The output of the code so far is shown in Figure 3-12.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig12_HTML.jpg
Figure 3-12

Hero banner head and body sections

Then, we proceed to creating the footer section of the Hero banner. The code is shown in Listing 3-13.
<div class="hero-foot">
    <nav class="tabs is-boxed is-fullwidth">
      <div class="container">
        <ul>
          <li>
            <a class="socicon-sharethis" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-facebook" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-twitter" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-snapchat" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-pinterest" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-linkedin" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-youtube" style="border:2px solid White;"></a>
          </li>
           <li>
            <a class="socicon-whatsapp" style="border:2px solid White;"></a>
          </li>
           <li>
            <a class="socicon-tumblr" style="border:2px solid White;"></a>
          </li>
         <li>
            <a class="socicon-mail" style="border:2px solid White;"></a>
          </li>
        </ul>
      </div>
    </nav>
  </div>
Listing 3-13

Adding the Footer Section

As you can see from the preceding code, we first create a separate <div> element, to which we assign the hero-foot class. Then we enclose a <nav> tag inside it and add the tabs class to create a navigation element at the bottom in the footer. We design the box for the footer and give it complete width using the is-boxed and is-fullwidth classes. Next, we create a container control using the container class. Inside the container, we create an unordered list and include the various list items using the <ul> and <li> tags. To those items, we assign the link using the <a> tag for each list item. We then assign a white border to those list items. You will observe that we used the socicon classes for each social media icon in the <li> tags.

For this, we have used the icons from the free Socicon web site at the following web address:

www.socicon.com

Note

For this example, we have used the Socicon CDN link on AWS servers in the <head> section of the Hero banner code along with the CDN link for Bulma CSS. Without adding the CDN link for Socicon, the code will not work; so make sure you include it in the <head> section.

<link rel="stylesheet" href="https://s3.amazonaws.com/icomoon.io/114779/Socicon/style.css?u8vidh">
After adding the respective socicon class (based on different social media icons), we can now see the final output in Figure 3-13.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig13_HTML.jpg
Figure 3-13

Full-height hero banner breadcrumb navigation & footer

As you can see, we have a full-height Hero banner with a breadcrumb navigation and a footer with several social media icons and other buttons like Share and Mail, to name a few.

Cards and Tiles

Cards are UI controls that help incorporate relevant information such as titles, user names, images, icons, and call-to-action buttons uniformly in a card format. All this data is shown with visuals on an equal pane. The flexibility and modular approach is prevalent across different sites like news postings, Tinder interfaces, and pictures seen under the Images tab in Google search, to name a few.

The card format delivers substantial information in a compact way with proper whitespace usage. It can also be used to group similar information in a consistent format across all viewpoints, ranging from desktops to mobile phones. For example, on an e-commerce site, information related to a specific genre of products is displayed in different rectangular cards along with their respective images with the same call-to-action functionality.

UI/UX designers promote the use of card-like design for its interactive and user-satisfying capabilities, as they can make effective use of the whitespace and deliver information in a compact form without clutter or noise. Moreover, cards demonstrate excellent responsiveness across all device or screen sizes, thereby bringing ultimate consistency and flexibility to your web site designing projects. Bulma also has an ingrained tile component, which is a card-like, metro-style container—a design previously observed in legacy Windows phones (think circa 2008–2010). Known as flat-and-modular design, it provides a high degree of readability of text and visuals, apart from ensuring a satisfying and interactive user experience across all breakpoints.

Let’s explore cards and tiles using simple examples. Initially we will see an example of cards before proceeding to tiles.

For the cards component, we will be using the card class. The card-image class is for images to be used in the card. The card-content class is for the titles and subtitles for the card and other text. For the footer, Bulma uses the card-footer class.
<div class="card">
    <div class="card-image">
    <figure class="image is-130x150">
      <img src="Images/Coffee-Shop-PixaBay.png" alt="Coffee-Shop-PixaBay">
    </figure>
    </div>
  </div>
Listing 3-14

Creating a Basic Card and Adding an Image

In Listing 3-14, we define a main <div> and use the card class with it. Then, we create another <div> element and assign the card-image class to it. Then, using the <figure> element, we insert an image source in the <img> tag.

The output of the code is shown in Figure 3-14.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig14_HTML.jpg
Figure 3-14

Image for the card on a mobile screen

Below the image, we define the card content. We create a <div> element and assign the card-content class to it. We assign a title and subtitle with different heading tags, using the title and subtitle class. Whereas we assign the is-4 class text size for the title, we use is-7 class text size for the subtitle. We also define a light grey color to the subtitle text using the has-text-grey-light class. Refer to Listing 3-15.
<div class="card-content">
      <p class="title is-4">SHREK CAFE</p>
        <p class="subtitle is-7 has-text-grey-light"> Italian & American Coffee</p>
      <div class="content is-size-6">
      European-influenced coffee shop for international snacks and coffee drinks using espresso bases
      </div>
    </div>
   <p class="card-header-title">
     <b> Reservation--> Book Now </b>
    </p>
Listing 3-15

Adding Content to the Image

The output of the card on a mobile screen after adding the content is shown in Figure 3-15.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig15_HTML.jpg
Figure 3-15

Card with the content and image

Then we define the footer for the card using the footer tags as shown in Listing 3-16:
<footer class="card-footer">
     <a href="#" class="card-footer-item"><b> 5:00 PM </b></a>
     <a href="#" class="card-footer-item"><b> 7:00 PM </b></a>
     <a href="#" class="card-footer-item"><b> 9:00 PM </b></a>
  </footer>
   <footer class="card-footer">
     <a href="#" class="card-footer-item"> <span class="icon is-large"><i class="fas fa-envelope fa-2x"></i> </span></a>
     <a href="#" class="card-footer-item"> <span class="icon is-large"><i class="fas fa-share-alt-square fa-2x"></i> </span></a>
     <a href="#" class="card-footer-item"> <span class="icon is-large"><i class="fas fa-comments fa-2x"></i> </span></a>
   <br>
  </footer>
   <footer class="card-footer">
    <a href="#" class="card-footer-item"> <span class="socicon-facebook"></span> </a>
      <a href="#" class="card-footer-item"> <span class="socicon-twitter"></span> </a>
      <a href="#" class="card-footer-item"> <span class="socicon-snapchat"></span> </a>
    <a href="#" class="card-footer-item"> <span class="socicon-pinterest"></span> </a>
      <a href="#" class="card-footer-item"> <span class="socicon-linkedin"></span> </a>
   <br>
  </footer>
Listing 3-16

Defining the Footer for the Card

In Listing 3-16, we create three <footer> elements. For each <footer> tag, we use the card-footer class.

In the first <footer> element, we create three links and assign the card-footer-item classes to them. We then jot down the booking timings as 5:00 p.m., 7:00 p.m., and 9:00 p.m.

In the second <footer> element, we create three links and assign the card-footer-item class to three items. However, we define the Font Awesome icons for Mail, Share, and Comments. We also increase the size of the icons by using the icon is-large and the exponential fa-2x classes for them.

In the third <footer> element , we create three links and assign the card-footer-item class to each of them. We then use the Socicon links for the five social media sites (Facebook, Twitter, Snapchat, Pinterest, and LinkedIn).

The output of the complete code is seen in Figure 3-16.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig16_HTML.jpg
Figure 3-16

Card with the content, image, and footer

In Figure 3-16, we can see the entire card we have created for Shrek Café.

Now, we look at the flat-design tile element. We define the tile by using the tile class with an element. In Bulma, the tiles have a particular hierarchy. Initially, the hierarchy is as follows:
tile is-ancestor
|
|---------tile is-parent
       |
       |--------- tile is-child
The is-ancestor class is the highest followed by the is-parent class, which in turn is followed by is-child, which is the lowest in the hierarchy. You can also nest tiles deeper than that. Following is the hierarchy for deeper child elements within connecting parent elements:
 tile is-ancestor
 |
 | ─tile is-vertical
 |   |
 |   |    |───tile
 |   |    |
 |   |    |───tile is-parent is-vertical
 |   |    |         └──tile is-child
 |   |    |        └───tile is-child
 |   |    |
 |   |    └───tile is-parent
 |   |             └───tile is-child
 |   |
 |   └───tile is-parent
 |           └───tile is-child
 └──tile is-parent
       └───tile is-child
Let’s further understand this using a code example.
<div class="tile is-ancestor">
  <div class="tile is-8 is-parent">
    <div class="tile is-4 is-child box">
      <p class="title">Column Ia</p>
      <p>Cat ipsum dolor ...amet </p>
    </div>
    <div class="tile is-5 is-child box">
      <p class="title">Column Ib</p>
      <p> Cat ipsum dolor ...amet </p>
    </div>
      <div class="tile is-child box">
      <p class="title">Column Ic</p>
      <p> Cat ipsum dolor ...amet </p>
    </div>
  </div>
  <div class="tile is-parent">
    <div class="tile is-child box">
      <p class="title">Column II</p>
      <p>Lorem ipsum dolor sit...ut quam    </p>
      </div>
  </div>
</div>
Listing 3-17

Creating Basic Tiles

In Listing 3-17, we initially create the main <div> element and assign it the tile is-ancestor class. Then we create the first child <div> element and assign it the tile is-parent and is-8 classes to define it as a parent element and the 8-column size it occupies. Within this parent, we have created three <div> elements. We assign a title and sample text for each of them. But the only difference in the three <div> child elements of the parent is the size allocated to each of them. The first child is four columns long due to the is-4 class. The second <div> child element is five columns long due to the is-5 class. The third <div>, whose size is not defined, takes up the remaining space automatically. We also assign a box class to each child in conjunction with the size and child class to create a box container.

Then we create a separate <div> for the second parent of the ancestor tile. We assign the tile is-child and box classes to the child inside the second parent. We also define the title and sample content for this child.

The output of the code is shown in Figure 3-17.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig17_HTML.jpg
Figure 3-17

Basic tile structure

As you can see, the first parent occupies eight columns space and contains three child elements. The second parent has taken the remaining space of four columns automatically, as the size is not defined.

In Bulma, you can also stack tiles vertically. Let’s understand it by using the example shown in Listing 3-18.
<div class="tile is-ancestor">
  <div class="tile is-9 is-vertical notification is-parent">
    <div class="tile is-12 is-child notification is-danger box">
      <p class="title">Column Uno</p>
      <p> Cat ipsum dolor sit .... cupidatat </p>
    </div>
    <div class="tile is-12 is-child notification is-primary box">
      <p class="title">Column Dos</p>
      <p> Cat ipsum dolor sit .... cupidatat </p>
    </div>
      <div class="tile is-12 is-child notification is-info box">
      <p class="title">Column Tres</p>
      <p>Cat ipsum dolor sit .... cupidatat</p>
    </div>
  </div>
  <div class="tile notification is-success is-parent">
    <div class="tile is-child notification is-warning box">
      <p class="title">Column Four Lorem</p>
      <p>Lorem ipsum ... ut quam Column</p>
Listing 3-18

Stacking Tiles Vertically

In Listing 3-18, we create one ancestor containing two parents. The first parent <div> is assigned a space of nine columns. We use the notification class to give it a bland contextual color. We also allocate the is-vertical class to this element. This will ensure that the child elements of the first parent tile will be stacked vertically. We create three child elements using the is-child class for each child <div> element.

For the first child element, we assign a tile of 12 columns of the parent size by using the tile is-12 class, and we also use the notification is-danger class to define the contextual color. Finally, we use the box class to create a box container for the first child. Thereon, we define the title and sample content for that child.

Similarly, we create two more child <div> elements. We assign the size of 12 columns for this child tile and define the is-primary and is-info classes to define its contextual colors. We also define a box container for their content using the box class, including the title and headings.

Following this, we create the second parent of the ancestor and define the contextual success color to the parent. Then we create a child for this parent and assign the contextual warning color to it. Moving forward, we define the title and sample content for this child.

The output of this code is shown in Figure 3-18.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig18_HTML.jpg
Figure 3-18

Child tiles stacked vertically for first parent, and second parent-child defined normally

As you can see, the first parent containing Column I Uno, Column I Dos, and Column I Tres child tiles are stacked vertically and occupy 12 columns horizontally. The second parent is a normal one with a single child. All parent columns and child columns show the size as defined in the code.

As explained earlier, you can have child elements much deeper within various parents. Let’s see a code example.
<div class="tile is-ancestor">
  <div class="tile is-8 is-vertical is-parent notification is-danger">
    <div class="tile is-12 is-child notification is-primary box">
      <p class="title is-size-4"><b>Column I Uno </b></p>
      <p>Cat ipsum dolor... cupidatat</p>
    </div>
    <div class="tile is-12 is-child box">
      <div class="tile is-parent">
      <div class="tile is-6 is-child notification is-warning box">
      <p class="title is-size-4"><b>Column I Dos Sub-Child I </b>  </p>
      <p> Cat ipsum dolor... cupidatat </p>
      </div>
      <div class="tile is-child notification is-info box">
      <p class="title is-size-4"><b>Column I Dos Sub-Child II </b></p>
      <p> Cat ipsum dolor... cupidatat </p>
      </div>
      </div>
      </div>
  </div>
  <hr>
  <div class="tile notification is-parent">
    <div class="tile is-child notification is-success box">
      <p class="title"><b>Column II </b></p>
      <p>Lorem ipsum dolor... orci,  </p>
   </div>
  </div>
  </div>
Listing 3-19

Nested Child Element Under Various Parent Tiles

In Listing 3-19, we create a main <div> with the tile is-ancestor class. Then we create the first parent element and give it a size of eight columns with the is-vertical class so that its child elements are stacked. We give it a danger contextual notification color.

Then we create a 12-column child element under the first parent element and assign the primary contextual color to it. We create another 12-column element child element under the first parent. Under the second child element, we create a parent element and create a nested tile that is six columns wide, and a second child element that will occupy the remaining space with the info primary color.

Now we have designed the first parent tile and its child tiles, followed by a nested parent inside the second child element, which in turn contains two child tiles.

So, at the start of the code we used the ancestor tile. Under the ancestor child tile, we create the second parent tile and use the notification color for the second parent and assign the success contextual notification color to it. Then we define the title, subtitle, and sample content inside it.

The output of the complete code is shown in Figure 3-19:
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig19_HTML.jpg
Figure 3-19

Parent child, child tile, and nested child tiles

Callout Panels and Box

Callout panels are containers with padding that create an inset box effect and highlight the content that separates it from the other usual content on a traditional web page. Apart from panels, Bulma also has a simple box element. Whereas boxes are used for normal content, panels are used for multiple elements like information sets and data tables, and may occasionally include forms. From a web design perspective, panels and boxes do not incorporate media and graphic content like cards or tiles do.

An important use of callout panels, in modern layouts especially, is to make the call-to-action elements stand out among the different content blocks. By singling out important information by adding more emphasis to a section or content, panels help get effective responses from the users.

We will see a step-by-step example of callout panels in Bulma in Listing 3-20.
<div class="columns is-multiline">
  <div class="column is-5">
 <nav class="panel">
  <p class="panel-heading">
   <b> Brands </b></p>
  <p class="panel-tabs">
    <a class="is-active">All</a>
    <a>New</a>
    <a>Refurbished</a>
  </p>
  <a class="panel-block is-active">Samsung </a>
  <a class="panel-block"> Nokia </a>
  <a class="panel-block"> OnePlus </a>
  <a class="panel-block"> Honor </a>
  <a class="panel-block"> Redmi </a>
  <a class="panel-block"> Huawei </a>
  <a class="panel-block"> Motorola </a>
  <a class="panel-block"> Sony </a>
  <a class="panel-block"> Apple </a>
   <a class="panel-block"> Asus </a>
  </nav>
  </div>
 </div>
Listing 3-20

Creating the First Panel

In Listing 3-20, we create the panel heading. Initially, we create a main <div> element and assign the is-multiline class to it in conjunction with the columns class. The entire code for the panels will be contained in the main <div> element.

Then, we define the column and assign a five-column width to it. Then we create the <nav> navigation element and assign the panel class to it. We move ahead to create a paragraph <p> element and assign the panel-heading class to it. We assign the Brands name as the panel heading. Then we create the panel tabs by using the panel-tabs class. Then we assign the names (All, New, and Refurbished) for the panel tabs. We add an is-active to the first panel tab, All.

Once the panel tabs are created, we create the list items using the <a> link tabs. For each link, we assign the panel-block class. We use the is-active class only for the first link, so that it shows that link chosen by default. Then we name different brand names of mobiles such as Samsung, Nokia, and Honor, to name a few.

The output of the code is shown in Figure 3-20.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig20_HTML.jpg
Figure 3-20

Panel with mobile phone brands

In Figure 3-20, we can see that the panel heading, panel tabs, and panel items are arranged as defined in the code. Then we define the second panel in the 12-column grid, which is assigned a size of 2 columns. We also use the is-offset-1 class so that this panel is one column away from the first panel. Let’s see the entire code for the second panel in Listing 3-21.
<div class="column is-2 is-offset-1">
  <nav class="panel">
  <p class="panel-heading">
    <b>Price</b>
  </p>
   <a class="panel-block">
   <= $100
  </a><a class="panel-block">
   <= $300
  </a><a class="panel-block">
   <= $500
  </a>
  <a class="panel-block">
   <= $750
     </a>
  </nav>
</div>
Listing 3-21

Creating the Second Panel

In Listing 3-21, we use the <nav> tag and assign the panel class to it. We define the panel-heading as Price, followed by the links containing the price rate range.

The output of this code is shown in Figure 3-21.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig21_HTML.jpg
Figure 3-21

Second price range panel next to the first panel

We then create another panel right below the second Price range panel.
<nav class="panel">
  <p class="panel-heading">
    <b>Color</b>
  </p>
   <p class="panel-block">
   <a class="button is-danger is-small"></a>
  </p>
  <p class="panel-block">
    <a class="button is-info is-small"></a>
  </p>
  <p class="panel-block">
   <a class="button is-warning is-small"></a>
  </p>
  <p class="panel-block">
   <a class="button has-background-black is-small"></a>
  </p>
  <p class="panel-block">
   <a class="button has-background-gray-light is-small"></a>
  </p>
 </nav>
Listing 3-22

Creating the Third Panel Below the Second Panel

In the preceding code, we use a navigation <nav> element and then define the panel heading as Color. We create five color contextual buttons panel blocks using the <a> link with the panel-block class.

The output of the code so far is shown in Figure 3-22.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig22_HTML.jpg
Figure 3-22

Three panels for brands, price, and color

Bulma also has a box layout, which we used previously in code. Let’s see an example of the box container in Listing 3-23.
<div class="box">
  <article class="media">
  <div class="media-content">
    <div class="content">
      <p>
        <strong class="is-size-4">Shrek-in-Matrix </strong>
        <br>
         Havana brown. Malkin. ..kittenz
        <br>
        <small><a><strong>Like <span class="icon is-medium"><i class="fas fa-heart"></i></span></strong>
        </a>   <a> <strong>Reply<span class="icon is-medium"><i class="fas fa-reply"></i></span></strong></a> ········ <strong><a>Share <span class="icon is-medium"><i class="fas fa-share-alt-square"></i></span></strong><a>
       </small>
      </p>
    </div>
  </div>
  </article>
</div>
Listing 3-23

Defining the Box Container

In Listing 3-23, we define a <div> class with the box class. Thereon, we define the <article> tag and assign the media class to it. Then, we create an element with the content class and add the heading and sample content in it. We also create three icons for Like, Reply, and Share using the Font Awesome-supported icon elements.

The output of the code is shown in Figure 3-23:
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig23_HTML.jpg
Figure 3-23

Box layout container

Incorporating Footers

Footers help designers add common information and navigation options at the bottom of the web pages. Copyright information, sitemaps, privacy policies, and contact information are usually included in the footer section. Links to important pages of the web site are normally a part of the footer section (more so in single-page web site design). Streamlining the footer information is also a way to enhance the SEO and UX/UI aspects of your web site (think good usability and readability practices), specifically on mobile and tablet devices.

Let’s see an example of a <footer> element in the following code (Listing 3-24). The Hero banner was explained earlier in the chapter; you may refer to that in Listing 3-12, which does not include the Hero footer part but does have sample content for the banner headings and body section. Only the footer section is explained here.
<footer style="background-color: Aqua;">
  <br>
      <div  class="has-text-centered has-text-black">
            <b> © 1999-2007 Shrek-in-the-Matrix @All Rights Reserved</b>
            <br>
            <p>Cat ipsum dolor ...for cupidatat </p>
      <div><br>
      <nav class="tabs is-boxed is-fullwidth">
      <div class="container">
        <ul>
            <li>
            <a class="socicon-sharethis" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-facebook" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-twitter" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-snapchat" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-pinterest" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-linkedin" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-youtube" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-whatsapp" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-tumblr" style="border:2px solid White;"></a>
          </li>
          <li>
            <a class="socicon-mail" style="border:2px solid White;"></a>
          </li>
    </ul>
   </div>
  </nav>
</footer>
Listing 3-24

Creating Footer Design

We use the <footer> element and assign the Aqua color to it. We enter the copyright sample message in the enclosed <p> tags. Then, we proceed to use a navigation <nav> element and assign the tabs, is-boxed, and is-fullwidth classes to it. Within that, we define a Bulma container using the container class. Similar to the Hero code, we create an unordered list of social media links from the Socicon web site.

The output of the code is shown in Figure 3-24.
../images/485437_1_En_3_Chapter/485437_1_En_3_Fig24_HTML.jpg
Figure 3-24

Footer section highlighted in a red box

Summary

In this chapter, we explored the different types of layout helpers such as containers, boxes, panels, media objects, and Hero banners, among others. These containers can be an alternative for grid structures, depending on the web site requirements.

In the next chapter, we will look at navigation and media components. These UI components are quite useful in building interactive web sites, a best fit for today’s effective digital layouts.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.171.136