Bootstrap causing partial failure in PHP script

I encountered an issue while trying to style a PHP file named dashboard.php using Bootstrap. Initially, I only included some HTML code in the file. Upon testing it, I noticed that the styling within the 'ul' tag was incorrect. However, other classes such as 'class="col-sm-2"' and 'class="row"' were functioning as expected.

<?php ?>

<!DOCTYPE>

<html>
    <head>
        <title>Dashboard</title>
        <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
        <script src="js/jquery-3.2.1.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
    </head>

    <body>
        <div class="container-fluid">
            <div class="row">
                <div class="col-sm-2">
                    <ul class="nav nav-pills nav-stacked" >
                        <li><a href="dashboard.php">
                        <span class="glyphicon glyphicon-th"></span>Dashboard</a></li>
                        <li><a href="#">
                        <span class="glyphicon glyphicon--list-alt"></span>Add New Post</a></li>
                        <li><a href="#">Categories</a></li>
                        <li><a href="#">Manage Admins</a></li>
                        <li><a href="#">Comments</a></li>
                        <li><a href="#">Live Blog</a></li>
                        <li><a href="#">Logout</a></li>
                    </ul>
                </div><!-- End of side area-->

                <div class="col-sm-10">
                </div><!-- End of main area-->
            </div><!-- End of row-->
        </div>
    </body>
</html>

In my attempt to resolve this issue, I generated a screenshot of the dashboard.php test: view image description here

Upon reviewing the image, you can see that the left side with words in blue pertains to the 'ul' tag, where the style is completely off. Additionally, the addition of glyphicon icons failed. Despite checking the syntax of my HTML code, no errors could be found.

Some additional information to note:

  1. The file has a .php extension
  2. XAMPP with Apache is running
  3. The URL used to access dashboard.php is correct: http://localhost/studyexample/PHPCMS/dashboard.php

Could you assist me in identifying why the styling within the 'ul' tag is inaccurate? Your help is greatly appreciated.

Answer №1

It seems like the issue here could be related to using relative URLs for your assets without a base tag. A quick fix would be to simply add a forward slash to the asset paths. When I tested your code on CodePen, it appeared to work as expected:

https://codepen.io/anon/pen/xyz123

To clarify, consider the following assets:

<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>

By updating the URLs to absolute paths with a forward slash, like so:

<link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css">
<script src="/js/jquery-3.2.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>

After making these changes, you should notice a difference in how your assets are loaded. If not, consider specifying the full path for each asset, such as:

<link rel="stylesheet" type="text/css" href="/fullpath/example/css/bootstrap.min.css">
<script src="/fullpath/example/js/jquery-3.2.1.min.js"></script>
<script src="/fullpath/example/js/bootstrap.min.js"></script>

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

Is it possible to override tags on a Bootstrap landing page?

Seeking assistance with a body tag override issue I am currently facing. Here is the webpage in question: I am attempting to implement a responsive full-screen background image on this page (homepage only) by utilizing the full.css file linked to the page ...

Switching the background image dynamically in Vue.js upon page access

My goal is to update the 'background-image' when the page is accessed. export default { created () { document.getElementsByTagName('html')[0].style.background = "url('../assets/background-blur.png') center" } } //Logi ...

Centered alignment with floating divs of abbreviated length

My HTML file has a structure similar to the following: <div style="float:right"> A line of text, floating to the right </div> <div style="text-align:center"> And here, several lines of<br /> text which should be centered. </div& ...

Utilizing jQuery to convert letter input values into English: a step-by-step guide

I am developing a basic web application using Jquery. In this application, I aim to restrict user input language. For instance, if a user enters the Russian letter б in the input field, I want to automatically convert it to an English character. Below is ...

Having trouble loading xml/xsl files on IE11? Consider enabling compatibility mode to ensure smooth rendering on your xml/xsl page

On my website, I have a page that displays XML from an XSL document. Strangely, it works perfectly on IE8 but not on IE11 - the page appears blank even though the XML is present when viewing the source. Interestingly, if I enable compatibility mode for the ...

Creating stylish components with MP4 styling techniques

Struggling to grasp React.js and facing challenges with styling using react, styled components, and Bootstrap. The ultimate goal is to display 3 gifs in a row with centered buttons and no spacing between them. Each gif should be 100vh. Below are all the e ...

The background video on the website is having trouble resizing properly to fit the screen dimensions

I'm new to coding and I'm attempting to incorporate a background video on the homepage. The issue arises when I resize my window or view it on a mobile device, as the video fails to adjust to the window size, causing side scrolling that reveals t ...

Manipulating divs by positioning them at the top, left, right, bottom, and center to occupy the entire visible portion of the page

Many suggest avoiding the use of table layouts and opting for divs and CSS instead, which I am happy to embrace. Please forgive me for asking a basic question. I am looking to create a layout where the center content stretches out to cover the entire visi ...

jQuery is not properly activating menu links

Below is the jQuery code I am using in order to add the class "active" to links within the navigation menu: $('.main__menu li a').click(function(e){ $('.main__menu li a').removeClass("active"); $(this).addClass( ...

Load a div using JavaScript to display the entire page within the div

Is there a way to reload a specific div using ajax:success without reloading the entire page within that div? $.ajax({ type: "GET", url: "http://192.168.2.210/sciAuthor1/personaldetails/cropImage", cache: false, success: function (respo ...

Positioning elements in relation to their parent container is key

I'm exploring the idea of positioning content after an absolutely positioned div that is nested within a relatively positioned div, without knowing the height of the relative div. Essentially, I have set up the following structure ... <div style= ...

Switch up the border color of the input in PrimeNG

Currently, I am utilizing PrimeNG with Angular and seeking to modify the shadow of the input box upon focusing it. Presently, it appears as follows: https://i.sstatic.net/o4eLw.png My preference is to change that blue portion to green. Upon reviewing the ...

Background image positioned behind a carousel

I'm currently working with a Bootstrap carousel that's functioning perfectly, but I have a desire to incorporate a background image behind this carousel. The background image should be at a width of 100% and 80% of the image should be covered by ...

Conceal the background of the lower div when the top div is displayed

I am struggling to figure out how to achieve this, or if it can even be done: <body> has a background image <div parent> has a background image <div child></div> does not have a background </div> My goal is to make the chi ...

Transferring HTML elements styled with CSS into Libre Office

Looking for a solution to transfer my HTML page, which is beautifully styled with CSS, into Libre Office Writer for editing. However, I am facing an issue where only the HTML content gets copied over without the accompanying style. Even after trying "Paste ...

AngularJS form submission with Ajax requiring a double click to successfully submit the form

I need to perform the following activities on my HTML page: User inputs email and password for registration Form is sent to Controller when user clicks Submit Controller uses AJAX to create JSON request to RESTful Server and receives response from server ...

Is there a way to customize the slot CSS for FormControlLabel?

mui5 "@mui/material": "^5.8.6", In order to achieve a lighter font weight for the label, I encountered an issue. https://i.sstatic.net/2JcpY.png Despite my efforts, the text still appears in bold: <FormControlLabel sx={{ label: ...

What is the best way to set breakpoints on Material UI components?

Currently, I am exploring material-ui and I'm curious if there is a way to set all breakpoints at once. The code snippet below seems quite repetitive. Is there a more efficient method to achieve this? <Grid xs={12} sm={12} md={12} lg={12} xl={12} ...

Issue with Google Map Pan Control Displayed Incorrectly on Internet Explorer 11

Currently, I am utilizing the Google Maps API v3 within my application. However, I have encountered an issue where the Maps Pan control is not displaying correctly on Internet Explorer 10 and 11. Interestingly, it seems to be functioning properly on Chrom ...

Customize the appearance of the "Collapse" component in the antd react library by overriding the default styles

Incorporating JSX syntax with *.css for my react component. Displayed below is the jsx code for the antd collapse section. <Collapse defaultActiveKey={["1"]} expandIconPosition="right" > <Panel header="This is p ...