unable to apply background to entire section

After using HTML5 and jquery to create a section, I attempted to set an image as the background. However, the image is not filling the entire section, leaving a 2px space around all sides inside the section. Below is the code I used:

<div id="container" data-role="page">
    <div style="..." data-role="header"><h>HOME</h></div>
    <section id="mainsection">
    </section>
</div>

CSS:

#mainsection
{
    height:40px;
    width:40%;
    margin-left:5%;
    margin-top:5%;
    float:left;
    background: url("images/pic99.png") no-repeat;
    background-size : cover;
    background-color:red;
}
Even after trying to use the background-size property in percentage, the issue persisted. Also, I am utilizing jquery-1.10.2.js, jquery.mobile-1.3.2.js, jquery.mobile-1.3.2.min.css. The background-color property sets correctly to 100%, but the problem arises when using an image in the background property.

Answer №1

Check out this Code Demo

Make sure to set the margin and padding to 0px for the #mainsection. Give it a try!

#mainsection{
    margin:0px;
    padding:0px;
}

Answer №2

#mainsection
{
    margin:0px !important;
    padding:0px !important;
}

Answer №3

give this a shot

.box {
width:100%;
height:50px;
}

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 on aligning a v-btn alongside v-expansion-panels on the same row

Struggling with aligning my layout. Trying to get a single set of v-expansion-panels and a v-btn in the same row, both visually centered within a card. I managed to almost achieve it in this codepen: https://codepen.io/anzuj/pen/PoPPbdw with the following ...

Can you use AJAX to retrieve the same URL in both HTTP and HTTPS protocols?

Is it possible to configure AJAX requests to retrieve files based on the protocol being used in the browser? I am aware that AJAX requests cannot be made from HTTP to HTTPS, so we are currently working on making content available through both protocols. F ...

Position tables on the right side of adjacent tables

There are two tables named id="BFCategories" and "BMICategories". Additionally, there are two other tables with id="BFTable" and "BMITable" BFCategories should come after BFTable, while BMICategories should follow BMITable. How can I a ...

JavaScript tri-state toggling

After devising 2 buttons, each intended to toggle a heading or paragraph, I encountered a slight issue. When using the 'Toggle Para' button, the switch occurs between 2 paragraphs upon 2 clicks. However, on the third click, I desire for both para ...

What is the reason for adding CSS styles to a JavaScript file without importing them?

/Navbar.js/ import './navbar.scss'; import {FaBars, FaSearch} from "react-icons/fa"; import { useState } from 'react'; function Navbar(){ const [hide,sethide] = useState(true); const barIcon = document.querySelectorAl ...

Issues with ajax functionality

Utilizing Codeigniter When clicked ... .. insert some code.... $.ajax({ url: '<?php echo base _ url(); ?>locations/getmap', dataType: 'json', type: 'POST', data: location_data, success ...

Error: The object does not contain the specified method

After deploying a web app to a remote host, I encountered an unusual error. Uncaught TypeError: Object #<error> has no method 'endsWith' Key Information: The application functions perfectly on my local machine as the host. The error ari ...

Frequent execution of jQuery Ajax requests is evident

Using a live operator, I attach a click function to a li-element: $(".UListView li input.iconbutton.click").live("click", function(e){ e.preventDefault(); [...] $.get("ajax/categorylist.php?appendcategories=true&parentcat="+currentid+"&side="+sid ...

Navigating to a Specific Section with a Fixed Header on Another Page

Trying to create a link to an anchor on Page 1 from Page 2, both of which have fixed headers. I'm utilizing the following script on both pages: $(document).ready(function(){ $('.testlink').bind('click', function(e) { e ...

JavaScript can be utilized to manage the exit events

Possible Duplicate: Alert when browser window closed accidentally Is there a way to trigger a new window to open when a user clicks the exit button (X) on the browser, similar to how the Wordpress Admin Panel functions? In the Wordpress panel, when t ...

Replacing a DOM Element on Page Load using jQuery

I am looking to substitute the following HTML element: <input type="submit" id="send_product_enquiry" value="Send Enquiry" class="button"> with this updated version: <input type="submit" id="send_product_enquiry" onclick="ga('send', & ...

Encountering an unspecified variable in Sass

I am a beginner in the world of sass and I am trying to incorporate a variable from a file named "_designs.scss" into another file called "_component.scss". Despite my efforts, I keep encountering an "Undefined variable: $grey-light-2" error. I have exhaus ...

What is the best way to stretch my background image to cover the entire screen?

I am working on a Python Django project and I want to create a full-screen background. The HTML code: { % load static %} <!DOCTYPE html> <html lang="en"> <head> <!-- Required meta tags--> <meta charset=" ...

The registration form's captcha did not prevent the submission of incorrect captchas

This is a PHP register.php page <?php require_once 'config.php'; ?> <?php if(!empty($_POST)){ try { $user_obj = new Cl_User(); $data = $user_obj->registration( $_POST ); if($data)$succ ...

Adding a pathway to a clip path: a step-by-step guide

While attempting to create a wave effect on an image, I hit a roadblock. There are two SVGs involved - one with the path I want to use and the other behaving as expected but with the wrong clip path/shape. However, when I try to insert the desired path, ...

Issues surrounding the break function in PHP and Jquery

Here is a simplified version of PHP and jQuery code for a page that I am working on. The example includes PHP break functions and the file is named test.php. The issue I am encountering is that when trying to load the first part of the page (case 1), the ...

Jquery for controlling the navigation menu

I'm new to JavaScript and facing 3 challenges: 1. When I click on the parent <li>, the correct content of the child <sub> does not show up. Each category like "colors, shapes, sizes" should have corresponding child categories like "green, ...

Remove the entry with attribute ajax from the database

I am facing an issue while attempting to delete using <li id='{$row['id']}'>. Although it successfully removes the item from the frontend, it fails to delete the record from the MySQL database. I am wondering if it is feasible to ...

Javascript dynamically generates CSS animations

I need assistance creating a div with a CSS3 animated timer inside it when a button is clicked. Here is the code I have been working on: http://jsfiddle.net/arcco96/y5nov6rz/1/. Unfortunately, the div is not being created as expected. I believe the code sh ...

Unable to place within div

Utilizing HTML5 to implement the "DnD" function. There is a button that adds divs. I want to be able to drag items into these newly added divs. Currently, I can only drag into existing divs and not the ones added later. How can I resolve this issue ...