Unable to change the font size within the Bootstrap framework

My struggle to change the font-size of text fetched from an AJAX request has been futile, leading me to consider using the !important declaration. Despite my efforts to place the font-size property in various locations, even inline, the dev console always displays Bootstrap's font size as active, with mine crossed out. Initially, the page loads default text in a 90px font, but upon clicking the button to retrieve remote server text, I am greeted with Bootstrap's smaller font size, typically around 14px. Below are my unsuccessful attempts at resolving this issue. Any suggestions?

<!DOCTYPE html>

<html lang="en">

        <!-- Bootstrap Links & Google Font Links-- Placement At Top Works Better in IDE used for Development -->
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
        <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Great+Vibes">
        <!-- style -->
        <style>
            body {
                font-family: Great Vibes, serif;
                background-color: #8A2BE2;
                font-size: 90px;
                color: #FFFFFF;
            }

            #display {
                background-color: #000000;
                color: #FFFFFF;
                font-size: 90px;
                min-height: 50%;
                min-height: 50vh;
                margin: 100px 200px 100px 200px;
                align-items: center;
            }

            /* word-wrap added to ensure quote remains in container */
            .quote-formatting {
                font-family: Great Vibes, serif;
                font-size: 90px;
                word-wrap: break-word;
            }

            #bootstrap-font-override {
                font-size: 90px;
            }

        </style>
        <script>
            $(document).ready(function () {

                $("#getQuote").on("click", function () {

                        $.ajax({
                            crossDomain: true,
                            dataType: "jsonp",
                            url:"https://api.forismatic.com/api/1.0/",
                            // appended to url in GET request as specified by API docs
                            jsonp: "jsonp",
                            data: {
                                method: "getQuote",
                                format: "jsonp",
                                lang: "en"
                            },
                            // take contents of JSON file from API and update html
                            success: function (json) {
                                var html = "";
                                html += '<h3>"' + json.quoteText + '"</h3>';
                                html += '<h5> -' + json.quoteAuthor + '</h5>';
                                $(".json-text").html(html);
                            },
                            // display when ajax request doesn't quite work out
                            error: function () {
                                alert("error!");
                            }

                        });
                    });
                });
        </script>
    </head>
    <body id="bootstrap-font-override">
        <div id="container-top" class="vertical-align container">
        <div class="container text-center">
            <h1>Heading</h1>
        </div>
            <div id="display" class="row">
                <div id="bootstrap-font-override" class="col-md-12 quote-formatting text-center">
                    <div style="font-size: 90px" id="bootstrap-font-override" class="json-text">Replace text on button click</div>
                </div>
            </div>
        </div> <!-- container-top -->
        <div id="container-btm" class="container">
            <div class="row">
                <div class="col-md-12 text-center">
                    <button id="getQuote" class="btn btn-default">Get Quote</button>
                </div>
            </div>
        </div> <!-- container-btm -->
    </body>
</html>

Answer №1

The h3 font style is being applied to the content you're wrapping, not the container itself. Your attempts to modify the container's styles won't work as expected.

To target the h3 specifically:

#bootstrap-font-override h3 {
    font-size: 90px;
}
// To avoid errors with $
$(document).ready(function () {

    $("#getQuote").on("click", function () {

        $.ajax({
            crossDomain: true,
            dataType: "jsonp",
            url:"https://api.forismatic.com/api/1.0/",
            jsonp: "jsonp",
            data: {
                method: "getQuote",
                format: "jsonp",
                lang: "en"
            },
            success: function (json) {
                var html = "";
                html += '<h3>"' + json.quoteText + '"</h3>';
                html += '<h5> -' + json.quoteAuthor + '</h5>';
                $(".json-text").html(html);
            },
            error: function () {
                alert("error!");
            }

        });
    });

});
body {
    font-family: Great Vibes, serif;
    background-color: #8A2BE2;
    font-size: 90px;
    color: #FFFFFF;
}

#display {
    background-color: #000000;
    color: #FFFFFF;
    font-size: 90px;
    min-height: 50%;
    min-height: 50vh;
    margin: 100px 200px 100px 200px;
    align-items: center;
}

/* Added word-wrap to ensure quote stays within container */
.quote-formatting {
    font-family: Great Vibes, serif;
    font-size: 90px;
    word-wrap: break-word;
}

#bootstrap-font-override h3 {
    font-size: 90px;
}
<html lang="en">

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Great+Vibes">

<div id="container-top" class="vertical-align container">
    <div class="container text-center">
        <h1>Heading</h1>
    </div>
    <div id="display" class="row">
        <div id="bootstrap-font-override" class="col-md-12 quote-formatting text-center">
            <div id="bootstrap-font-override" class="json-text">Replace text on button click</div>
        </div>
    </div>
</div>
<div id="container-btm" class="container">
    <div class="row">
        <div class="col-md-12 text-center">
            <button id="getQuote" class="btn btn-default">Get Quote</button>
        </div>
    </div>
</div>

Answer №2

It is necessary to customize the styling of both h3 and h5 headings

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

The appearance of HTML is acceptable in a browser but appears differently in an email

I'm encountering an issue with email encoding. After reading an HTML file from disk and sending it through Gmail, the content appears distorted when received. Even the list bullets are messed up! Despite encoding the file as UTF-8, everything looks fi ...

`Weaving mesh into place with three.js`

I'm struggling to grasp how to position my cubes on the canvas. I can't quite figure out how positioning actually works. I'm trying to find a way to determine if my mesh reaches the limits of the canvas. But what exactly is the unit of posit ...

Retrieving and displaying all anchor tags within a designated div element

So I'm facing a small issue with my portfolio website (you can check it out at this link) The problem arises when clicking on a portfolio piece, as the top section should open up to display details such as title, year, role, and description along wit ...

Discrepancy in Line Spacing in Internet Explorer 9 when Working with TextAreas

My TEXTAREA requires precise spacing, so I've set the formatting as shown below: TEXTAREA { font-family: Tahoma, Arial; font-size: 8pt; letter-spacing: 0px; line-height: 13px; } The issue arises when typing text into the textarea - the li ...

Issues with Carousel Plugin Functionality

**Hey everyone, I could really use some help. As a beginner coder, please forgive any errors in my code. I am currently working on a webpage where I need to incorporate a carousel plugin within a panel body to display the latest photos. The code provided ...

Although my header remains stationary, my body content flows smoothly as I scroll

After applying a high z-index to the header, it appears beautifully, but unfortunately, none of the links in other divs are clickable. I seem to be missing something obvious, yet can't pinpoint the issue. Any assistance would be greatly appreciated! ...

"What is the most efficient method to display or hide multiple divs using

Hey, I'm trying to figure out how to work with showing or hiding multiple div elements quickly. Do I really need to number each div like "open,close,show_text"? It seems a bit repetitive if I have to do it for each div 10 times. Open 1 Close 1 hell ...

Sorting table data by Table SubHeadings using Jquery

Utilizing jQuery tablesorter in my UI, I encountered a challenge with a table that has 2 rows of headers - one main header and one subheader. My goal is to enable sorting on the subheader. How can I achieve this? Below is an example of my code structure: ...

Enhance your web design with the mesmerizing jQuery UI drop effect combined

I'm attempting to create an animated toggle effect on a box using jQuery UI's drop feature. However, I've encountered some trouble due to the box having box-sizing: border-box applied which is causing issues with the animation. During the a ...

Tips for creating several radio buttons with separate functionality using Bootstrap 5

Is there a way to create separation between these two groups of radio buttons? Whenever I select an option in one group, it automatically deselects the option in the other group. <!DOCTYPE html> <html lang="en"> <head> ...

Issues with Laravel 5.8 and Bootstrap not functioning properly in Jquery

Check out this link for using Bootstrap Select. The code works perfectly in the view, but when I try to implement it with jQuery below, it doesn't work. Can someone help me fix this issue? View Code: <table id="tableAppointment" style=&q ...

Transform Vector into HTML5 Canvas (DXF to Canvas coordinate conversion)

Can we convert DXF drawings into HTML5 code that replicates the image on a canvas? ...

what distinguishes CSS properties for Id versus class selectors

Currently in the process of creating my inaugural website, which consists of just four pages. Each page follows the standard layout structure with a header, navigation bar, content division (div id="content"), and footer. As I delve into adding CSS proper ...

Navigation website with a twist

My design features a main navigation that is rotated 90 degrees, while the sub-menu remains horizontally aligned. <div id="nav"> <ul> <li><a href="#">Woonaccessoires</a></li> ...

Simple steps to add a click event listener to every element within a div

I need to assign a click handler to multiple elements and perform different actions based on which one is clicked. To illustrate, I can create an alert displaying the class of the button that was clicked. The elements I am working with have a similar str ...

Eliminate the empty choice for Angular when dealing with dynamic option objects

Looking for assistance with this code snippet: <select ng-model='item.data.choice' > <option ng-if='item.data.simple_allow_blank == false' ng-show='choice.name' ng-repeat='choice in item.data.simple_choices&ap ...

The JavaScript code for window.event fails to function properly in the Firefox browser

Here is a code snippet: <div id="uploadControl" class="fileUpload1"> <label for="uploadFile" id="labelId">Choose File</label> <input class="upload" type="file" id="uploadFile" /> ...

Is it possible to conceal the portion of an element that is obscured by another?

https://i.sstatic.net/ZR8M7.png When applying a hover effect in the image, you can see that the green box appears below. Is there a way to prevent the intersecting part from showing during hovering over the yellow box? Here is the code snippet: <div ...

ng-grid defines different cellClass based on the value of the field

I am currently using the ng-grid and I want the column to display in a different color based on different values. I have tried, but not succeeded so far... $scope.gridOptions = { ........ columnDefs: [ { field: "status", displayName: "St ...

You cannot apply Contextual Classes to override Table Header Colors Classes like .thead-dark or .thead-light

I am currently learning about tables in Bootstrap 4. I am facing an issue where the background-color in the table-light class is not being applied. I suspect this might be due to the thead-dark class taking precedence over it. Could you please clarify why ...