How do I make two sub divs appear side by side in a large div? What exactly does float left do.

Updated on educate 2024-03-15
8 answers
  1. Anonymous users2024-02-06

    float:left is left floating, so many theories are in vain. The elements are as follows:

    First of all, the sum of the widths of the two divs A and B cannot be greater than the width of the divs of the parent layer, otherwise the lines will be folded.

    Second, both a and b should be set to float:left.

    Then, in order to be compatible with browsers, you need to add a clear style to put it below the ab two divs. In this way, if you add other divs to the big div, there will be no large blank space, and the other divs will not be occluded.

    In addition, you can use position to float elements on top of the layer, and the positioning is clear, accurate, and hierarchical. As for how to use it, I'll refer to it myself. It's a lot of trouble, so I won't write much.

  2. Anonymous users2024-02-05

    Scenario 1: The div with the float set is on the left side, and the div without the float will think that there is no element there, so the second one is still in the first position.

    Situation 2: If the float is set, then B knows that there is a div in that position, so B will follow A.

    Case 3: The float element will only drift behind the previous element.

    float: Drifts the element so that it is fixed to the right or left, and the other elements are distributed around the drifting element.

    So the drift element must be specified with width

  3. Anonymous users2024-02-04

    As a web page maker, the float attribute stone is versatile and must be proficient, and web pages are divided into floating streams and standard streams.

    float is a floating stream.

    The main function of float is to make the element out of the standard flow into a floating flow, which can be understood in disguise as allowing an element to have the attributes of an in-line element and a block-level element, which can be both materialized and displayed in a row.

    Situation 1: It's like a person flying up and floating on top of another, what flies up is the floating flow (the floating flow is not place-occupied), and the person standing on the ground is the standard flow B, so B is covered by A, but this situation is generally not allowed to appear in a box at the same time floating flow and standard flow, to float are floating. Because floating elements affect non-floating elements.

    Situation 3: The div is a block-level element that occupies one line, so A does not float and occupies one line, and B runs to the second line.

  4. Anonymous users2024-02-03

    There are generally three ways to make two divs appear side by side in HTML, including:

    1) Set the inline style, display:inline-block(2) set the float.

    3) Set the position positioning attribute to absolute, and the following are the specific implementations of the three ways**

    1. Set the display attribute of each div to the in-line style, the example is:

    div1div2

    2. Set floating, example ** is:

    div1div2

    3. Set the position positioning attribute to absolute, and the example is:

    div1div2

  5. Anonymous users2024-02-02

    There are three main methods:

    Use the inline property of display.

    Set the float so that the divs are displayed side by side.

    For two divs side by side, the left side is the absolute width and the right side is the relative width, and this layout is often used, such as the left side is the navigation side and the right side is the content page.

    The maximum container padding-left is fixed width, the left is fixed width for a piece of position:absolute, and then the right piece is 100% width.

    Use position:absolute

  6. Anonymous users2024-02-01

    html:**。

    I wrote it briefly. div1

    div2css**:

    dd hehe, I don't know if you understand???

  7. Anonymous users2024-01-31

    Examples are as follows:

    1) Create a big div first.

    ** As follows: main

    2) Create a small left div

    **As follows: left

    3) Create a small div on the right

    ** As follows: right

    4) Make it into a CSS file, or add it directly to the web page, you can achieve side-by-side display.

    This is a floating method, if your divs are not displayed side by side, then you need to pay attention to the width, because as long as the width is enough, the two divs can be displayed in a row. There are two small divs in the div.

    You can first define a layer with div, and then give two ** floating attributes in the layer, so that it will not happen ** to run to the next line, the default style attribute of the div box itself is an exclusive line, and there are usually two ways to solve the div exclusive line, one is to set the float, and the other is to set the display style. Here's another way.

    We add display:inline to solve the problem of displaying div box objects side-by-side.

    Set the div style for the div tag, in order to distinguish other objects that do not need to be arranged horizontally to display the div box, we will bold the css class for the adjacent div boxes that need to be displayed in the same row, and the css is named".div-inline"。

  8. Anonymous users2024-01-30

    1.First, define a main div and then add two smaller divs to it. Function: Use the main div to control the effect of two small divs side by side. **As follows:....Add what you're going to show here....

    Add what you're going to show here....

    2.Now use styles to control the side-by-side effect. There are two ways to do this. One. Layout by overall pixel width. …Add what you're going to show here....

    Add what you're going to show here....

    Note: The sum of the widths of the left and right divs is equal to the width of the main div. The effect is shown below.

    3.Two. Layout by percentage width. …Add what you're going to show here....Add what you're going to show here....

    Note: The sum of the proportions of the left and right divs is equal to the proportion of the main div. The effect is shown below.

Related questions
22 answers2024-03-15

1. Create a new html file, named it, to explain how to set the div height of jquery. >>>More

6 answers2024-03-15

It is advisable not to stop the drug easily!

Most dogs with canine plague will have a recovery period after taking antiviral drugs such as monoclonal antibodies and serum. >>>More

21 answers2024-03-15

There is still such a strange phenomenon in life, ten years of long-distance running still can't match the reality, and some people can get married in just a few months. How long have two people been together? Is it the best way to get married? >>>More

6 answers2024-03-15

Intimate your relationship with it and make it listen to you.

6 answers2024-03-15

Hello! You first go to the cultural market to buy a GHOT automatic XP installation disk 5 yuan - 10 yuan, and then boot into the BIOS to set the optical drive priority start, boot up, press the keyboard up and down left and right keys to select "Manually run ghost" item, enter the ghost interface, select local--- select patition--- select from image, press the tab key to select the top big box, press enter, press the up and down keys to select the included extension. ghofile, select it and press enter. >>>More