Do mobile CSS/HTML have distinct rules to follow?

I am having trouble displaying a background image in CSS. Additionally, I am unable to set a background color for a div.

#mlogo {
    background-image: url(/mobileimages/2015LOGOFB.jpg);
    background-size: 100%;
    background-position: top;
    background-repeat: no-repeat;
    position: relative;
    width:100%;
    text-align:center;


}


#mwrap {
    background-color: black;
    position: relative;
    width:100%;
    text-align:center;
    overflow:hidden
}



#mindex {
    background-color:black;
    position: relative;
    width:100%;
    text-align:center;
    border-style: solid;
    border-width: 1px;
    border-color: #a1a1a1;

}

The browser seems to be recognizing the CSS, as some of the elements are displaying correctly. These are the specific divs I am trying to work with.

<div id="mwrap">

<div id="mlogo" align="center">

</div>

<div id="mindex" align="center">
<p id="menu1">Photo And Video</p>
</div>

<div id="mindex" align="center">
<p id="menu1">Scores</p>
</div>

<div id="mindex" align="center">
<p id="menu1">Standings</p>
</div>


</div>

I am developing a separate mobile site for an existing desktop site. Thus far, I have tested my code on an Android (Galaxy 4) and iPhone 6, and both displays appear identical.

I cannot figure out why the image is not showing as the background of the div, nor can I understand why I am unable to set the background color of the entire site to black. The image does display if I use <img src""> in the HTML, but not when I add it to the CSS of the div box I am using to define different sections of the site.

<!DOCTYPE html>
<html>
<head>
 <link rel="stylesheet" type="text/css" href="mobilesummer.css">
 <title>SSL 2015</title>

<meta name="viewport" content="width=device-width; initial-scale=1.0;">

</head>

This is the contents of my head tag.

I am feeling lost on this issue...am I making something simple more complex than it needs to be?

Answer №1

The divs lack a specified height, resulting in them not containing the content properly.

One solution could be to eliminate position:relative and instead add float:left; along with width:100%; This approach will enable the div to adjust its height based on the content, assuming you do not require the relative property.

I hope this suggestion proves helpful.

Answer №2

The background image is not visible because the div with id #mlogo does not have a defined height. Try setting a height of 400px

If you wish to change the entire site's background to black, you can use this CSS code:

body {
  background-color: black;
}

UPDATE :

I created a pen, where I added a sample image and included a red border to #mindex

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

How can one extract information from an ASP.NET MVC on a separate webpage?

Experimenting with ASP.NET MVC for the first time here, so bear with me if this comes across as textbook-like. A basic content management system has been developed using ASP.NET MVC. The URL to retrieve a list of content, specifically announcements, looks ...

Dynamically add onClick events using JavaScript to perform multiple identical actions

While I can't provide all the code here, I believe this snippet can illustrate my issue: for(var i = 0 ; i < 5 ; i++) { $('#mybutton').on('click', function() { return false; }); $('#mybutton').on('click&apo ...

The Firefox parent was not appearing on the screen

I'm facing an issue with Firefox not displaying my website properly. It seems to be struggling with the styling of a parent div. Have a look at these images. Here is how it's supposed to appear: My website in Chrome/IE http://www.lackeycomputing ...

Ways to verify the content within two separate p elements

<p> expanded state:</p> <P> true </p> Merging the text from both tags into a single output. Final Output: expanded state: true ...

Is there a translation issue affecting Chrome version 44?

Recently, Chrome 44 (44.0.2403.89 m) was released and I've encountered some issues with the translate3d feature (on both Mac and Windows versions). This problem is impacting plugins such as fullPage.js and consequently affecting numerous pages at th ...

Guide to placing an element behind text using Bootstrap 3

On my webpage, I have a straightforward Bootstrap Jumbotron displayed prominently: <div class="jumbotron"> <div class="container"> <h1>Welcome to My Wonderful Site</h1> <p>There's some information her ...

Which specific html container or element can be found on the mymsn pages?

When accessing mymsn, users have the ability to personalize the content and layout of their webpage. I am curious about what type of container is being utilized for this customization - does it involve an html element, or perhaps javascript, or something e ...

Tips for implementing validation in a multi-step form as outlined in w3schools tutorial

I came across a multistep form creation tutorial on w3schools. However, the tutorial only covers generic validation (checking if a field is empty), which is not sufficient for my needs. How can I implement HTML validation (e.g., min, max, length) for text ...

Can you provide me with the validation expression for the email format in ASP.NET?

Currently, I am working on validating a text field where users need to enter an email address following a specific format: [email protected] Here are the rules for the email validation: 1) The email address must end with .com. No numbers are allowed ...

Enhance Your Map with Bootstrap 4 - Integrate a Unique Theme Color

Is there a way to incorporate a new custom theme color without having to modify the bootstrap variable.scss file directly? I have successfully updated existing colors, but I am struggling to add a completely new theme color using the same method. File st ...

Interested in learning how to filter nested tables?

After successfully integrating a filter code snippet, I encountered an issue with the filter not recognizing data tables that can only be inserted as nested tables. Due to my limited knowledge of JavaScript/CSS, I'm unsure if this problem can be resol ...

Improprove Google PageSpeed score - must resolve

My mobile website is loading incredibly slow, despite my attempts to improve the speed using Google PageSpeed insights. Unfortunately, I'm having trouble interpreting the screenshot and identifying what changes need to be made. Is there anyone who c ...

When exporting to Excel from ASP.NET, the generated files cannot be opened properly in Excel Viewer

My goal is to transfer dynamic data from an ASP.NET website to Excel without using Excel XML or installing Excel on the server. I discovered that the most straightforward method is to output the data as a table and specify the type as application/vnd.ms-ex ...

Saving JSON data as a file on server

Currently, I am running a localhost website on my Raspberry Pi using Apache and I am seeking advice on how to export a JSON string to a file on the Raspberry Pi itself. While I do know how to export a file, I am unsure of how to send it to the Raspberry Pi ...

Is there a problem with the way divs are being displayed when using jQuery to show the first 12 elements with the class "hide-show"?

I am encountering a problem with displaying data using the jQuery slice() and show() methods to reveal dynamically generated divs from a PHP function. The code is as follows: <style> .hide-show { display :none; } </style> <div class="c ...

When the nav menu toggler in Bootstrap 4 is clicked on a mobile screen, it causes the content to

When I view this on xs or sm screens and click on the navbar toggler, it pushes all the content, including the header where the toggler is located, down the page to accommodate the dropdown menus. This behavior seems to be different from Bootstrap 3 and Bo ...

Adding dashes as padding in HTML/CSS

I am currently working on updating the user management block on my website and I want to showcase it with some visual examples. I believe that using images is the most effective way to demonstrate changes. This is the current appearance of the block: ...

Tips for aligning text to the left within a Bootstrap accordion

I am in the process of developing a static website utilizing the W3schools "Company" theme. The complete code for this website, including CSS, is provided below: <!DOCTYPE html> <html lang="en"> <head> <!-- Theme Made By www.w3schoo ...

In the IE7 standards mode, table cells with no content will have a height of 1px

When utilizing IE7 standards mode within IE9, empty table cells are automatically assigned a height of 1px. As a result, elements positioned beneath the table appear lower on the page than intended. To view an example of this issue, refer to the code provi ...

Form is protected from XSS attacks

Here's a basic form that I'm attempting to exploit with XSS using Chrome. <?php echo $_GET['comment']; ?> <script>alert('from HTML')</script> <form method="GET" action=""> Name: <input t ...