Stylish CSS for Bootstrap4 Form Wizard Navigation


I'm currently in the process of building a form wizard using Twitter's Bootstrap 4 framework.
My goal is to have the navigation within the modal's header, and the buttons located in the modal's footer.
Unfortunately, I'm facing challenges with creating arrow designs using CSS similar to this example: https://codepen.io/tiagorigoletto/pen/HCtDE.
For reference, here is my JSFiddle link: https://jsfiddle.net/kirtan3d/hxLfs20z/

Below is the HTML code I've implemented:

<div class="modal" id="registrationModal" style="position: relative; display: block; width: 700px;">
    <div class="modal-dialog modal-lg" role="document">
        <div id="bs4wizard" class="modal-content">
            <div class="box-head box-head-accent-2" style="position: absolute;"></div>
            <div class="modal-header">
                <nav id="wizardNav" class="nav">
                    <a class="nav-link active" href="#step1" data-toggle="tab" aria-controls="step1" role="tab" title="Step 1">
                        Confirm Mobile
                    </a>
                    <a class="nav-link disabled" href="#step2" data-toggle="tab" aria-controls="step2" role="tab" title="Step 2">
                        Personal Information
                    </a>
                    <a class="nav-link disabled" href="#step3" data-toggle="tab" aria-controls="step3" role="tab" title="Step 3">
                        Business Information
                    </a>
                </nav>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div id="wizardTab" class="tab-content">
                    <div class="tab-pane fade show active" role="tabpanel" id="step1">
                        <h3>Step 1</h3>
                        <p>This is step 1</p>
                    </div>
                    <div class="tab-pane fade" role="tabpanel" id="step2">
                        <h3>Step 2</h3>
                        <p>This is step 2</p>
                    </div>
                    <div class="tab-pane fade" role="tabpanel" id="step3">
                        <h3>Step 3</h3>
                        <p>This is step 3</p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <div id="wizardBtn">
                    <button type="button" class="btn btn-secondary prev-step">Back</button>
                    <button type="button" class="btn btn-secondary skip-step">Skip</button>
                    <button type="button" class="btn btn-primary next-step">Save and Continue</button>
                </div>
            </div>
        </div>
    </div>
</div>

This is the implementation of my CSS styles:

#wizardNav a {
    color: #fff;
    background: #0275d8;
    border: solid 1px #025ead;
    border-width: 1px 0;
    text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.30);
    box-shadow: inset 0px -1px 0px rgba(0, 0, 0, 0.20);
}
#wizardNav a:first-child {
    border-radius: 0.3rem 0 0 0.3rem;
    border-right:0;
}
#wizardNav a:last-child {
    border-radius: 0 0.3rem 0.3rem 0;
    border-left:0px;
}
#wizardNav a.disabled {
    opacity: 0.6;
    background-color: #666;
    border-color:#555;
}
...
(wizardNav styling continues)
...
    

I also made use of simple jQuery for certain functionalities:

(Only applicable if needed)

$(".next-step,.skip-step").click(function (e) {
    var $activeN = $('#wizardNav .nav-link.active').next();
    $activeN.removeClass('disabled');
    $activeN.prev().addClass('pass');
    $activeN.trigger("click");
});
$(".prev-step").click(function (e) {
    var $activeP = $('#wizardFormNav .nav-link.active').prev();
    $activeP.trigger("click");
    if ($activeP.hasClass('active')) {
        $activeP.removeClass('pass');
    } else {
        $activeP.addClass('pass')
    };
});

Answer №1

I have made some tweaks to your fiddle, but feel free to experiment with padding and border sizes as needed.

Check out the updated fiddle here

#wizardNav {
  overflow: hidden;
}

#wizardNav a {
  background-color: #E4E4E4;
  border-radius: 5px;
  display: inline;
  padding: 10px 100px 10px 30px;
  margin-right: -7px;
  width: auto;
  position: relative;
}

#wizardNav a::before, #wizardNav a::after {
  border: solid transparent;
    content: " ";
  top: 0;
  bottom: 0;
    position: absolute;
  border-color: transparent;
    border-left-color: #fff;
  border-radius: 10px;
}

#wizardNav a::before {
    border-width: 43px;
    right: -15%;
    z-index: 3;
    top: -15%;
    height: 130%;
}


#wizardNav a:after {
    border-left-color: #E4E4E4;
    border-width: 43px;
    right: -10%;
    top: -15%;
    height: 130%;
    z-index: 4;
  z-index: 4;
}

#wizardNav a.selected {
  background-color: #FF4F65;
  color: #fff;
}

#wizardNav a.selected::after {
  border-left-color: #FF4F65;
}

#wizardNav a:last-child {
  padding: 10px 30px;
}

#wizardNav a:last-child::after, #wizardNav a:last-child::before  {
  content: none;
}

For further enhancements, I have added more HTML markup in this update, incorporating rotated pseudos for angled effects and fixed height for links:

Take a look at the latest version of the fiddle here

This is my recommended solution based on the changes made.

Answer №2

Perhaps this information could be of assistance to you, even though it may not be precisely what you were seeking.

    $(".next-step,.skip-step").click(function (e) {
var $activeN = $('#wizardNav .nav-link.active').next();
$activeN.removeClass('disabled');
$activeN.prev().addClass('pass');
$activeN.trigger("click");
});
$(".prev-step").click(function (e) {
var $activeP = $('#wizardFormNav .nav-link.active').prev();
$activeP.trigger("click");
if ($activeP.hasClass('active')) {
$activeP.removeClass('pass');
} else {
$activeP.addClass('pass')
};
});
#wizardNav a {
color: #fff;
background: #0275d8;
    border: solid 1px #025ead;
border-width: 1px 0;
text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.30);
    box-shadow: inset 0px -1px 0px rgba(0, 0, 0, 0.20);
   text-align:center;
}
#wizardNav a:first-child {
border-radius: 0.3rem 0 0 0.3rem;
border-right:0;
}
#wizardNav a:last-child {
border-radius: 0 0.3rem 0.2rem 0;
border-left:0px;
}
#wizardNav a.disabled {
opacity: 0.6;
background-color: #666;
border-color:#555;
}
#wizardNav a.pass {
background-color: #5cb85c;
    border-color: #5cb85c;
}
#wizardNav a:hover {
background-color: #025aa5;
    border-color: #01549b;
}
#wizardNav a.disabled:hover {
opacity: 0.6;
background-color: #666;
border-color:#555;
}
#wizardNav a.pass:hover {
background-color: #449d44;
    border-color: #419641;
}

#wizardNav a::after {
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
border-color: transparent;
border-left-color: #fff;
}
#wizardNav a::after {
border-left-color: #2b2b2b;
    border-width: 33px;
    margin-top: -33px;
    margin-left: 38px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="modal" id="registrationModal" style="position: relative; display: block; width: 700px;">
<div class="modal-dialog modal-lg" role="document">
<div id="bs4wizard" class="modal-content">
<div class="box-head box-head-accent-2" style="position: absolute;"></div>
<div class="modal-header">
<nav id="wizardNav" class="nav">
<a class="nav-link active" href="#step1" data-toggle="tab" aria-controls="step1" role="tab" title="Step 1">
Confirm Mobile
</a>
<a class="nav-link disabled" href="#step2" data-toggle="tab" aria-controls="step2" role="tab" title="Step 2">
Personal Information
</a>
<a class="nav-link disabled" href="#step3" data-toggle="tab" aria-controls="step3" role="tab" title="Step 3">
Business Information
</a>
</nav>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div id="wizardTab" class="tab-content">
<div class="tab-pane fade show active" role="tabpanel" id="step1">
<h3>Step 1</h3>
<p>This is step 1</p>
</div>
<div class="tab-pane fade" role="tabpanel" id="step2">
<h3>Step 2</h3>
<p>This is step 2</p>
</div>
<div class="tab-pane fade" role="tabpanel" id="step3">
<h3>Step 3</h3>
<p>This is step 3</p>
</div>
</div>
</div>
<div class="modal-footer">
<div id="wizardBtn">
<button type="button" class="btn btn-secondary prev-step">Back</button>
<button type="button" class="btn btn-secondary skip-step">Skip</button>
<button type="button" class="btn btn-primary next-step">Save and Continue</button>
</div>
</div>
</div>
</div>
</div>

Answer №3

Just using a simple combination of Bootstrap 4 and Fontawesome on this page:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Stepper</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>

<div class="panel">
  <h1>Stepper</h1>
  <div class="row">
    <div class="col-md-auto ml-1 text-secondary"><i class="fa fa-check-circle-o" aria-hidden="true"></i> Fill out your contact </div>
    <div class="col-md-1 m-0" ><hr/></div>
    <div class="col-md-auto" ><i class="fa fa-circle-o" aria-hidden="true"></i> Fill out your car information</div> 
    <div class="col-md-1" ><hr/></div>
    <div class="col-md-auto text-secondary" ><i class="fa fa-circle-o" aria-hidden="true"></i> Done</div>
  </div>
</div>

</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips for creating a seamless Bootstrap collapse effect

I have noticed a slight flicker in the content collapse when using this code. Is there a way to make it collapse more smoothly? <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> <script ...

How to use JQuery to parse an external JSON file with array elements in Javascript

My goal is to extract information from an external JSON file using JavaScript, specifically an array and other elements. The JSON file I am working with is called 'TotalUsers.json' {"@version":"1.0", "@generatedDate":"12/20/10 5:24 PM", "day":[{ ...

Tips for adjusting the width of a div within a panel to make it full-width

Is there a way to create a full-width div in a side panel using jQuery Mobile? I attempted it, but the result is not as desired: https://i.sstatic.net/kfxj7.png This is my current code snippet: #profile { background-color: green; border-botto ...

Firefox is having issues when trying to print an iframe that is styled with display:none

Currently, I am implementing code obtained from an answer on Stack Overflow to enable direct printing of a separate page upon clicking a print button. The mechanism involves sending a URL to the print function which then loads the separate page into an ifr ...

Resolution-specific CSS styling

As a newcomer to website development, I have some knowledge of CSS, HTML, and Javascript. However, I am encountering issues with my website. When viewed on low screen resolutions or mobile devices, the right side of my site is cut off, making it impossible ...

Maintain the selected bootstrap tab even after the page is refreshed, even when the content is loaded dynamically

I am currently facing an issue with loading tabs using Angular. Whenever a tab is clicked, the id is saved to localStorage. Now, I want to programmatically click on the same tab using jQuery when the page refreshes. However, since the DOM element for the ...

PHP while loop to iterate through a specific number of rows

Having some trouble with a while loop in PHP. My goal is to fetch quotes from a database and display them in 3 columns per row. Currently, the while loop only displays one column per row. How can I fix this issue? <?php $servername = "localhost"; $ ...

Is TYPO3 version 8.7 bundled with JQuery?

After upgrading my TYPO3 from version 6.2.31 to 8.7.19, I've encountered some issues with JS/JQuery. I recall reading somewhere that JQuery should be automatically included in the new TYPO3 version. Can anyone confirm this for me? Appreciate any ass ...

Alerts being used by Jquery Validation Engine to showcase errors

In the validation engine, my goal is to have error messages appear in a JavaScript alert box instead of as small tooltips right next to the input fields. $("#main_form").bind("jqv.form.result", function(event, errorFound) { if(errorFound) aler ...

How can I position my navbar above my background image using Bootstrap?

I am a newcomer to using bootstrap and I am attempting to create the following design: https://i.sstatic.net/EV9A1.png In the design, the navbar is situated on top of the background image. However, with my current setup, this is what I have: <!DOCTYPE ...

What is the process for triggering an unordered list when I click on a table data cell within the Hospitals category?

Hi there! I need help with writing a JavaScript function for Hospitals in the code below. When I click on Hospitals, I want to display the values in the unordered list. Expected output: Hospitals--->onclick Bangalore| salem |Goa| Mangalore| Visakhapat ...

How to center an image within a WordPress .php file

Could someone please assist with centering the image in the code snippet below? add_action('woocommerce_after_add_to_cart_button', 'add_content_on_add_to_cart_button'); function add_content_on_add_to_cart_button() { echo &qu ...

Applying a color gradient to a specific spot on the page, regardless of how far down users scroll

I have implemented a CSS code to add a shadow effect to the top part of my webpage, similar to what Facebook does on user profile pages. While this works well for shorter pages, I am encountering issues with longer pages where the shadow extends too much a ...

Organize column 1 on top of column 2 for mobile display

Currently, I am utilizing the grid system with 2 columns set up as follows: <div class="row"> <div class="col-md-6"> 1 </div> <div class="col-md-6"> 2 </div> </div> ...

Remove the items from the class dropdown list on the TinyMCE link button and popup

When using TinyMCE and clicking the link button, a popup window will appear asking for link details. One of the fields in this popup is for adding a CSS "Class". Is there a way to clear this list? I noticed that there is a plugin setting within advlink wh ...

What is the best way to collapse additional submenus and perform a search within a menu?

Whenever a sub-menu is activated, only the current sub-menu should be open while the others remain closed. I need the search function to be enabled on the text box and display all items containing the specified value while also changing the color of <a ...

Bootstrap 4 - Ensuring Tables are Mobile Responsive and Precisely Sized for Desktop viewing

Allowing users to customize table column widths in percentages that total up to 100 provides flexibility. However, this results in cramped tables on mobile devices. To address this issue, I aim for the table to become horizontally scrollable with the boo ...

Best practices for managing checkboxes in ASP.NET

I've recently delved into the world of asp.net core, and now I'm venturing into regular asp.net development. My current challenge is to implement a select all/deselect all checkbox feature. What I've noticed is a significant difference betwe ...

What is the reason for this script making two separate calls to the server?

After multiple attempts, I am still stuck trying to figure out the issue at hand. This Javascript snippet is part of a Chrome extension's popup functionality. $('#save').click(function() { var baseURL = 'http://example.com/endpoint ...

How can you use Jquery's .data() method to find elements with specific values?

I have a button that generates a new drop pin. The pin is contained within a div, and a hidden form input is also created to store the position of the pin when it's dragged. In my jQuery code for creating these elements, I assign a data attribute call ...