disobedient divs

I have noticed that elements on my page are breaking out of the "wrapper" div. Here is the HTML structure I am using:

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="stilovi.css" rel="stylesheet" type="text/css"/>
        <link href='http://fonts.googleapis.com/css?family=Philosopher' rel='stylesheet' type='text/css'/>
    </head>
    <body>
        <div id="wrapper" class="centrDiv">
            <div id="levo">
                <div id="logo" class="centrSlik">
                    <img src="wheel.gif"/>
                </div>
                <div id="podmeni">
                    <ul>
                        <li><a href="#">test</a></li>
                        <li><a href="#">test</a></li>
                        <li><a href="#">test</a></li>

                    </ul>

                </div>


            </div>
            <div id="desno">
            <div id="meni">
                <ul>
                    <li></li>
                </ul>

            </div>


            <div id="tekst">
                <p>
                  ttaatareatasfgfgfd
                </p>

            </div>
            </div>
        </div>
    </body>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script>
</html>

Below you can see the CSS styles being applied:

* { padding: 0; margin: 0; list-style: none; font-family: 'Philosopher', cursive; text-decoration: none; color: black;}
#wrapper{width: 930px; height:100%; margin-top: 15px; background-color: #71637D;}
#meni{background-image: -webkit-gradient(linear, left top, right bottom, from(#FF9999), color-stop(100%, #71637D)); padding: 8px 15px 10px;
-webkit-border-bottom-left-radius: 10px 20px; -webkit-border-top-right-radius:10px 20px; border: 1px solid #FF9999; opacity:0.9; -webkit-box-shadow: 5px 5px 20px #4AC0F2;}
#levo{width: 130px; min-height: 350px; background-image: -webkit-linear-gradient(top, #71637D 120px, #4AC0F2);
         float: left;}
#tekst{padding: 20px 15px;}
#tekst p{margin-bottom: 10px;}
#logo{background-color: white;}
#desno{width: 800px; min-height: 350px; background-image: -webkit-linear-gradient(-75deg, #71637D 30%, #4AC0F2); float: right;
-webkit-border-top-right-radius:10px 20px; }

#podmeni ul{height: 220px; -webkit-border-image: -webkit-gradient(linear, left top, left bottom, from(#FF9999), color-stop(100%, #4AC0F2)) 0 100% 0 0/0 5px 0 0 stretch;}
#meni li{letter-spacing: 2px; font-size: 16px; font-weight: bold;  display: inline; margin-right: 5px;}
#meni li:hover{-webkit-border-image: -webkit-gradient(linear, right top, left top, from(#FF9999), color-stop(100%, transparent)) 0 0 100% 0/0 0 5px 0}
#meni a{text-shadow: 0.1em 0.1em #333;}

.centrDiv{margin: 0 auto;}
.centrSlik{text-align: center;}
.nevidljivo{display:none;}

After inspecting with Firebug, I noticed that all elements are outside of the div#wrapper. I am trying to figure out why this is happening.

Answer №1

To resolve the issue, consider adding a "clearfix" or applying float:left to the #wrapper.

Here are some examples:

Clearfix: http://jsfiddle.net/GR2fT/1/

Float: http://jsfiddle.net/GR2fT/2/

overflow:hidden: http://jsfiddle.net/GR2fT/3/

overflow:auto: http://jsfiddle.net/GR2fT/5/

/* Implementing clearfix */
.clearfix:after,
.clearfix:before {
    content: "\0020";
    display: block;
    height: 0;
    overflow: hidden;
}  
.clearfix:after {
    clear: both;
}  

Even with these changes, the elements remain within the #wrapper, though the background may not be visible.

Clearfix is beneficial when you cannot utilize float (when width is unknown but you desire 100% width).

The overflow technique can also be effective, particularly in modern browsers, but it may not always be suitable.

For more information, refer to: Is clearfix deprecated?

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 act of looping with for loops can be quite disruptive to

I need to display some basic 3D objects (specifically THREE.Sphere which contains 1-30 other THREE.Spheres with RGB color and no texture) in a somewhat real-time animation. The rendering process is quick, but I am facing issues with simple iterative calcu ...

Ensure all columns have the same height as the shortest column

While many solutions exist on Stack Overflow for making columns equal height based on the largest content, I am specifically interested in making all columns equal height based on the smallest column. https://i.sstatic.net/Xlcyh.png In this scenario, my ...

What is the best way to incorporate a scroll bar into a table that updates dynamically?

If I were to create an empty table in my index.html: <body> <table width="800" border="0" class="my-table"> <tr> </tr> </table> </body> Afterward, I would dynamically add rows and columns to my-table using ...

Transferring the value stored in the value attribute to a different PHP page?

I am attempting to pass the value from the value attribute in button using a form with the method POST to "landlord_home.php". However, when I click on the button to navigate to the next page "edit_post.php", it triggers the PHP validation code on that pag ...

The webpage is not displaying any results despite using .innerHTML with Ajax

I am currently developing a web application that displays query results using the Google Books API. While my code is functioning, I am encountering an issue where the .innerHTML method does not show any results on the HTML page. Below is the HTML code bein ...

Are there more effective methods for determining the precise CSS values needed for a 3D transformation, rather than relying solely on trial and error?

Having a 3D iPhone vector, I am looking to create a sprite animation of screens on top of it. To achieve this, I am using a div as a mask over the iPhone, with the sprite background animating through transition and background-position. The iPhone is alrea ...

Streamlining all icons to a single downward rotation

I am currently managing a large table of "auditpoints", some of which are designated as "automated". When an auditpoint is automated, it is marked with a gear icon in the row. However, each row also receives two other icons: a pencil and a toggle button. W ...

How can I use HTML and jQuery to send a button click event to a .py file using AJAX and cgi in web development?

I have encountered a challenge with posting data from button clicks on an HTML page to Python CGI for insertion into a PostgreSQL database. My script seems to be struggling with this task. Here is the structure of my HTML, ajax, and javascript: '&ap ...

Utilize ajaxFileUpload.js to upload 3 images from various input type files in CodeIgniter effortlessly

I'm looking to enhance my code by enabling the upload of three images from different input types along with a text field using a single submit button function. The current code works fine when uploading only one file, but issues arise when attempting ...

Need to conceal certain images in Isotope, but ensure they can easily be revealed when necessary?

I have a collection of various images on my website coded with isotope. My question is, how can I hide specific images that I don't want to display initially, but have them appear when needed? I have managed to create a "show all" list using the code ...

Aligning a rotated paragraph in the middle of its parent container

Here is my current progress: http://jsfiddle.net/2Zrx7/2/ .events{ height:100px; position: relative; } .tt_username{ position: absolute; top:0px; height: 100%; width: 30px; background: #ccc; text-align: center; } .tt_usern ...

Drag to rotate using JavaScript when the mouse is pressed down

I am experimenting with making a spinning wheel rotate as the user drags the mouse over it. The wheel consists of 3 pieces, so I have individually mapped each image to target the specific section of the wheel that I want to rotate. Currently, it is funct ...

Using a glass of water as a metaphor to illustrate advancements in CSS and JQuery

I've been working on a new app and have recently started implementing some significant changes. The app has a unique feature that allows users to track their water intake and compare it to their set goal. One key aspect I am struggling with is creati ...

Exception Regarding Security in My Java Applet

Every time I try to use an applet, I encounter the java.lang.SecurityException: Permission denied: file:////Videos/public/scripts/screenshot.jar error. Below is the applet code that I am having trouble with: <applet code="Screenshot" archive="file:/// ...

Conceal a div once the user scrolls to a certain position using vanilla JavaScript

As a beginner in the field of web development, I am currently working on creating a blog website. Code Function - One of the challenges I'm facing is implementing a floating pagination bar that needs to be hidden when a visitor scrolls near the foote ...

The height of Bootstrap 4 beta columns causes a conflict with the navigation bar,

Using Bootstrap Beta 4, I've encountered an issue where my nav element is overlapping my column div. What could be the cause of this problem? <html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstr ...

What is the best way to ensure the search box remains fixed in the top navigation bar while maintaining a fluid and responsive design?

I've been struggling as a novice programmer, and even with the help of more experienced programmers, we haven't been able to figure it out. I'm trying to integrate a search box into the top navigation that adjusts responsively to different ...

Add flair to the elements contained within a div that has been assigned a class

What I am capable of doing: Creating HTML: <div id="test"> HELLO! <input type="text"> </div> Styling with CSS: #test { color:#F00; } #test input[type=text] { background-color:#000; } Now, if the #test is replaced with ...

Is there a way to see the default reactions in a browser when keyboard events such as 'tab' keydown occur?

Whenever I press the 'tab' key, the browser switches focus to a different element. I would like to be able to customize the order of focused elements or skip over certain elements when tabbing through a page. While I am aware that I can use preve ...

Inconsistent behavior of transform scale() between Chrome and Safari upon page refresh

My goal was to design a code that would adjust all content according to the browser size, ensuring that everything remains visible even when the window is resized. var docHeight = $(document).height(); var winHeight; var zoomRatio; function z(number) { ...