


HTML>Proficient in CSS DIV web page style and layout>Understanding CSS positioning and DIV layout>Self-understanding of float attributes_html/css_WEB-ITnose
Jun 24, 2016 pm 12:30 PM
With my love for ASP.NET front-end development, I looked at the float attribute this morning. To be honest, it is quite complicated.
Let me give you my example first. My self-understanding is all in this example. There are still some imperfections, the clear attribute is not put up.
< html >
< head >< title > float屬性的自我理解 title >
< style? type ="text/css" >
.father
{
????background-color : #fffea6 ;
????border : 1px?solid?#111111 ;
????padding : 25px ;
}
.oldbrother
{
????padding : 10px ;
????margin : 5px ;
????background-color : #70baff ;
????border : 1px?dashed?#111111 ;
????float : none ;
}
.youngbrother
{
????padding : 5px ;
????margin : 0px ;
????background-color : #ffd270 ;
????border : 1px?dashed?#111111 ;
}
style >
< script? type ="text/javascript" ?src ="JS/jquery-1.4.2-vsdoc.js" > script >
< script? type ="text/javascript" >
????$( function ()?{
????????$( " #nofloat " ).click( function ()?{
????????????$( " .oldbrother " ).attr( " style " ,? " float:none; " );
????????????$( " .youngbrother " ).attr( " style " ,? " float:none " );
????????});
????????$( " #leftfloat1 " ).click( function ()?{
????????????$( " .oldbrother " ).attr( " style " ,? " float:left; " );
????????});
????????$( " #rightfloat1 " ).click( function ()?{
????????????$( " .oldbrother " ).attr( " style " ,? " float:right; " );
????????});
????????$( " #nofloat1 " ).click( function ()?{
????????????$( " .oldbrother " ).attr( " style " ,? " float:none; " );
????????});
????????$( " #Fumargin " ).click( function ()?{
????????????$( " .oldbrother " ).attr( " style " ,? " float:left;margin:5px?0?0?-35px; " );
????????});
????????$( " #leftfloat2 " ).click( function ()?{
????????????$( " .youngbrother " ).attr( " style " ,? " float:left; " );
????????});
????????$( " #rightfloat2 " ).click( function ()?{
????????????$( " .youngbrother " ).attr( " style " ,? " float:right; " );
????????});
????});
script >
head >
< body >
元素占用的空間有div塊級(jí)(block),span行內(nèi)級(jí)(inline)之分。block,占用一行空間,撐滿父元素;inline,占用的空間僅僅是自身content padding border margin。 < br? />
要知道block,inline,都有float屬性,即浮動(dòng)。不設(shè)置浮動(dòng)屬性,默認(rèn)float為none。 < br? />
哥哥屬性設(shè)置浮動(dòng)后,其弟弟元素的內(nèi)容包圍哥哥元素,哥哥元素不再屬于父元素。 < br? />
弟弟元素設(shè)置浮動(dòng)后,對哥哥元素沒影響,但同樣不屬于父元素。 < br? />< br? />
< br />
< div class ="father" >
< div class ="oldbrother" > brother element div >
< div class ="youngbrother " > younger brother element div >
div >
< div style =" clear:both;" >
< input type ="button" id =" nofloat" value ="Set the elder brother element to have no float" />< br />
< input type ="button" id ="nofloat1" value ="Set the elder brother element to have no float" /> ;
< input type ="button" id ="leftfloat1" value ="Set the element to left float" />
< input type ="button" id ="rightfloat1" value ="Set The brother element is floated to the right" />
< input type ="button" id ="Fumargin" value ="Set the margin attribute of the brother element to a negative number and float left" />< br />
< input type ="button" id ="leftfloat2" value ="Set the younger brother element to left float" />
< input type ="button" id ="rightfloat2" value ="Set the younger brother element Float right" />
div >
< div style ="float:left" > This is a block element. div >
< div > This is a block-level element. This is a block level element. This is a block level element.
This is a block-level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. div >
< span style ="float:left; background-color:Gray;" > This is an inline element. span >
< div style ="border:dotted 1px black" > This is a block-level element. This is a block level element. This is a block level element.
This is a block-level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. This is a block level element. div >
body >
html >
Of course, downloading is provided. /Files/samwu/Self-understanding of float attributes.rar

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

ARIA's role attribute is used to define the role of web elements and improve accessibility. 1. Role attribute helps assistive technology to understand the functions of elements, such as buttons, navigation, etc. 2. Use role attributes to assign specific roles to non-semantic HTML elements. 3. The role attribute should be consistent with the element behavior and be verified by the accessibility tool test.

How to create a website layout? 1. Use HTML tags to define the content structure, such as, ,. 2. Control styles and positions through CSS, using box model, float or Flexbox layout. 3. Optimize performance, reduce HTTP requests, use cache and optimize images, and ensure responsive design.

Improve the readability and maintainability of HTML code can be achieved through the following steps: 1. Use semantic tags, such as, etc. to make the code structure clear and improve SEO effect; 2. Keep the code formatted and use consistent indentation and spaces; 3. Add appropriate comments to explain the code intention; 4. Avoid excessive nesting and simplify the structure; 5. Use external style sheets and scripts to keep the HTML concise.

The key to keep up with HTML standards and best practices is to do it intentionally rather than follow it blindly. First, follow the summary or update logs of official sources such as WHATWG and W3C, understand new tags (such as) and attributes, and use them as references to solve difficult problems; second, subscribe to trusted web development newsletters and blogs, spend 10-15 minutes a week to browse updates, focus on actual use cases rather than just collecting articles; second, use developer tools and linters such as HTMLHint to optimize the code structure through instant feedback; finally, interact with the developer community, share experiences and learn other people's practical skills, so as to continuously improve HTML skills.

The reason for using tags is to improve the semantic structure and accessibility of web pages, make it easier for screen readers and search engines to understand page content, and allow users to quickly jump to core content. Here are the key points: 1. Each page should contain only one element; 2. It should not include content that is repeated across pages (such as sidebars or footers); 3. It can be used in conjunction with ARIA properties to enhance accessibility. Usually located after and before, it is used to wrap unique page content, such as articles, forms or product details, and should be avoided in, or in; to improve accessibility, aria-labeledby or aria-label can be used to clearly identify parts.

To create a basic HTML document, you first need to understand its basic structure and write code in a standard format. 1. Use the declaration document type at the beginning; 2. Use the tag to wrap the entire content; 3. Include and two main parts in it, which are used to store metadata such as titles, style sheet links, etc., and include user-visible content such as titles, paragraphs, pictures and links; 4. Save the file in .html format and open the viewing effect in the browser; 5. Then you can gradually add more elements to enrich the page content. Follow these steps to quickly build a basic web page.

To create an HTML checkbox, use the type attribute to set the element of the checkbox. 1. The basic structure includes id, name and label tags to ensure that clicking text can switch options; 2. Multiple related check boxes should use the same name but different values, and wrap them with fieldset to improve accessibility; 3. Hide native controls when customizing styles and use CSS to design alternative elements while maintaining the complete functions; 4. Ensure availability, pair labels, support keyboard navigation, and avoid relying on only visual prompts. The above steps can help developers correctly implement checkbox components that have both functional and aesthetics.

HTMLtagsareessentialforstructuringwebpages.Theydefinecontentandlayoutusinganglebrackets,ofteninpairslikeand,withsomebeingself-closinglike.HTMLtagsarecrucialforcreatingstructured,accessible,andSEO-friendlywebpages.
