Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 991591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:08:04+00:00 2026-05-16T06:08:04+00:00

I have a div with a padding, created and styled by Javascript. This div

  • 0

I have a div with a padding, created and styled by Javascript.
This div is created on a page with the following CSS rule:

div {
    width: 100%;
}

This messes up, as it changes the width of my created div to what it naturally would be PLUS its padding (so I end up with buttons outside of the div borders). I can’t statically set div widths because they depend on the content. So how can I overwrite this rule and bring it back to “default width”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T06:08:05+00:00Added an answer on May 16, 2026 at 6:08 am

    You need the following CSS:

    div { width: auto; }
    

    Since the CSS rule is applied through JavaScript, which causes it to be an inline style, you may have to use !important to make sure the new rule has a higher specificity so you can overwrite the old one.

    div { width: auto !important; }
    

    Of course, it would be even better if you could just edit the JavaScript so it wouldn’t add the style to the div anymore.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 541k
  • Answers 541k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer That plugins is poorly designed, if the element has more… May 17, 2026 at 2:52 am
  • Editorial Team
    Editorial Team added an answer This is an excellent question and something that always bothered… May 17, 2026 at 2:52 am
  • Editorial Team
    Editorial Team added an answer Tomcat's default configuration on Ubuntu must be using a security… May 17, 2026 at 2:52 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

In some page, my side menu is created dynamically like this. <div id=tree class=treeview>
I have an HTML page. I have created a frame using background repeat function.
I have created an iframe code that I want people to use as a
I have created a simple flash menu and the SWF file, JS files (swfoject.js
I have an ASP.NET page where i will check whether the user has logged
I am having a problem with my web page, because I have a wrapper
Okay, I'm trying to be clear on this one... I have some insliding boxes,
I am trying to insert rows into an html table with javascript. I have
I have created a menu and submenu bar for my web app. Now with
Consider the following HTML and CSS. The desired result is the two pink boxes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.