Customize your website with eye-catching full width colored blocks using Bootstrap 3

I am in need of colorful full-width blocks to differentiate the sections on my website.

Currently, I am constructing my website with Bootstrap 3 within a standard container. However, I would like certain sections to be vibrant blocks that span across the entire browser window.

If anyone is familiar with how this can be achieved and could provide an example, I would greatly appreciate it!

Answer №1

To create full-width colored blocks, you need to nest the container within another tag that spans the entire width of the page using a CSS background attribute. In this example, I have used the HTML5 "section" tag. Below is a sample code snippet. You can check out the jsfiddle for reference.

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Bootstrap 3 - Full width coloured blocks</title>

<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">

<style type='text/css'>
    .colored-block {
        width: 100%;
        padding: 30px 0px;
        color: #fff;
    }
    .purple { background: purple; }
    .green { background: green; }
    .blue { background: blue; }
</style>

</head>

<body>
    <section class="colored-block purple">
        <div class="container">
            <h1>Header 1</h1>
            <p>Paragraph content goes here</p>
        </div>
    </section>
    <section class="colored-block green">
        <div class="container">
            <h1>Header 2</h1>
            <p>Paragraph content goes here</p>
        </div>
    </section>
    <section class="colored-block blue">
        <div class="container">
            <h1>Header 3</h1>
            <p>Paragraph content goes here</p>
        </div>
    </section>
</body>
</html>

Check out the jsfiddle for a live example.

Answer №2

Here is a simple way to illustrate your issue using three different colors: red, green, and blue.

<div class="row">

        <div class="col-md-4 ">
        <p class=text-danger> red color</p> 
        </div>

        <div class="col-md-4 ">
            <p class=text-success> green color</p>      
        </div>

        <div class="col-md-4 ">
            <p class=text-primary> blue color</p>       
        </div>

</div>

Answer №3

Check out this jsfiddle featuring a layout with 3 columns and full height background colors.

jsfiddle

CSS:

html,body,.container-fluid
{
  height:100%;
}
.container
{
display:table;
width: 100%;
}
.row
{
height: 100%;
display: table-row;
}
.col-md-4, .col-xs-4
 {
display: table-cell;
float: none; 
}

.red{background:red;}

.green{background:green;}

.blue{background:blue;}

HTML

 <div class="container">
 <div class="row">
 <div class="red col-xs-4 col-md-4">.col-xs-4 .col-md-4</div>
 <div class="blue col-xs-4 col-md-4">.col-xs-4 .col-md-4</div>
 <div class="green col-xs-4 col-md-4">.col-xs-4 .col-md-4</div>
 </div>
 </div>

Answer №4

To create colorful full-width sections in Bootstrap, simply replace 'container' with 'container-fluid'.
Example:
CSS:

.red{background:red;}
.green{background:green;}
.blue{background:blue;}

HTML:

<div class="container-fluid">
    <div class="row">
        <div class="red col-xs-12">.col-xs-12 .col-sm-12 .col-md-12 .col-lg-12</div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="blue col-xs-12">.col-xs-12 .col-sm-12 .col-md-12 .col-lg-12</div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="green col-xs-12">.col-xs-12 .col-sm-12 .col-md-12 .col-lg-12</div>
    </div>
</div>

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

"Limitation observed - function operates only on first attempt

I have been working on a map project that involves pulling information from Google about various locations using the library available at https://github.com/peledies/google-places In order to troubleshoot and identify the issue with the code related to ma ...

Error in onchange event due to incorrect index variable

My goal is to add onchange events to select tags within a div that contains multiple tags. To achieve this, I am using a for loop to attach events to each tag. The purpose of these events is to update a select tag in another container by removing the "disa ...

Is it possible to customize the CSS styles of a jQuery UI modal dialog box?

Having trouble with my CSS styles not applying to a dialog modal added to my website using jQuery UI, even when using '!important'. I suspect that the predefined jQuery or UI CSS styles from a CDN link are preventing me from overriding them. The ...

Incorporating input fields into an HTML form

I'm looking to enhance my form by adding input fields dynamically through the JavaScript function when I click on the add button: let i = 0; function increment() { i += 1; } function addFieldFunction() { let newDiv = document.createElement(&apos ...

What can be done to improve the elegance of this jQuery function?

I am facing an issue on my webpage where I have a drop-down select box with a default value of (empty). The problem arises when the user selects an entry, and the appropriate form for that entry type should be displayed. However, there are a couple of iss ...

Activate anchor classes in several anchor link menus simultaneously

I have a one-page website with multiple menus filled with anchor links. Here is an example of what they look like: <ul> <li><a href="#home" class="active" onclick="closeNav();">Home</a></li> <li><a href="#abo ...

Problem with Safari: File downloaded with name "Unknown" due to Javascript issue

After successfully converting my data to text/csv, I can easily download the file in Chrome. However, when attempting to do so in Safari on an iPad or Mac, it opens a tab with the name "unknown" or "Untitled". The code snippet I am using for this is as fol ...

Guide to vertically aligning text in an overlay using CSS within Angular 2

I currently have an overlay on my page that displays a spinner (an Angular material component) and accompanying text. This overlay covers the entire page and prevents clicking on elements below it. The spinner is positioned in the center of the page, and ...

The script functions perfectly in jsfiddle, yet encounters issues when used in an HTML

I stumbled upon a seemingly peculiar issue with my script in jsfiddle: https://jsfiddle.net/oxw4e5yh/ Interestingly, the same script does not seem to work when embedded in an HTML document: <!DOCTYPE html> <html lang="en"> <head> & ...

"Although disabled, input elements can still be focused on in Firefox browser

Illustrative example let userInput = document.createElement("input"); userInput.id = "user-input"; userInput.type = "number"; userInput.className = "user-number-input"; userInput.disabled = true; document.body.appendChild(userInput); .number-inp ...

Spring REST service prevents Cross-Origin Requests with AJAX

Having Trouble Accessing Spring REST Service My spring service @RequestMapping(value = "/MAS/authenticate", method = RequestMethod.POST) public ResponseEntity<Map<String, String>> authenticate(@RequestBody Subject subject) { Map<String ...

I encountered an issue with my foreach loop where the checkbox failed to properly send the value

Having an issue with the checkbox not sending the desired value. This is my HTML code for the checkbox. I am using a foreach loop. <form id="signupform" autocomplete="off" method="post" action="inputchecklist.php" class="form_container left_label"> ...

Submitting an AJAX form redirects to a different page instead of keeping the user on the current page

I've encountered an issue with my popup ajax form. Instead of staying on the same page after data submission, it redirects me to send.php file. This behavior is different from another website where I successfully implemented a similar form. I'm n ...

Using Express.js to serve simple SVG files (Technique involving Cheerio.js)

My goal is to manipulate SVGs before sending them through Express.js. The code snippet I am using is as follows: app.get("/iconic/styles/:style/:base/:icon", function (req, res) { var style = req.params.style; var base = req.params.base; var i ...

javascript Incorrectly using location.reload will not refresh the page as intended

My goal is to refresh a page every time a user clicks a button so the page reverts back to its original source code. However, I am facing an issue where the location.reload() function is being executed after the code instead of at the beginning. btn.addEve ...

JavaScript vs. markup: deciding between generating an extensive list of options or including them directly in

Recently, I encountered an issue with a .NET page that included a large number of identical dropdown lists within a repeater. Unfortunately, the rendering performance of the website was below expectations. In an attempt to improve the performance, I exper ...

changing the vertical position of an element using JavaScript

I'm currently working on a project where I have a canvas that animates upwards when a button is clicked. However, I'm facing an issue with making it go back down after the animation completes. It seems to be getting stuck and not returning to its ...

Trigger a function when the browser automatically populates an input field

I am attempting to trigger a function that can detect if the browser has autofilled a field and then add a specific class to it. After finding a thread with a solution that mostly works, mentioned here: Here is how I implemented it: $.fn.allchange = fun ...

Using Jquery to swap out div elements and reinitialize code after selecting a menu <a href>link<</a>

I have a jQuery script that swaps out a div when a href="#1" is clicked. The same link, a href="#1", is then replaced by a href="#2" and vice versa. Here is the jQuery code: $('.child2, a[href="#1"]').hide() $('#replacepagelinks a').c ...

What is the best way to change the size of an SVG image

I have exhausted all the methods I could find on stackoverflow and Google, but my SVG is refusing to resize. Would someone kindly shed some light on why this might be happening? <div> <svg viewBox="32 32 32 32" height="100" width="100"> ...