HTML text picture how vertical

How is the word picture of HTML? This issue may be often seen in our daily study or work. I hope that you can give you a deep harvest through this issue. Below is the reference content brought by Xiaobian, let’s take a look!

Method 1: Set the height of the box with line-height, this method is suitable for a line of text.

Picture vertical centrifugal and one line of text Allowance attribute vertical-align

small icon and text vertical alignment, small icon is inserted as background

// attr: Set yourself Attribute, like Selected Checked This class is Undefinded, using the mouse point over his value is undefinded, so the self-owned property is recommended to include the size and location of the containing block

. The calculation is often determined by the block in which the element is located, and includes a block that does not specifically refers to an element area, but a piece of visual imperative, understanding that he can be able to position it.
How do you know where an element is included?

The initial containing block
User agent (such as browser) selects the root element as Containing Block (called the initial containing block). When the child of HTML does not have other contained blocks, it will rely on the initial contained block to position,
initially contains the size of the block? That is, the viewport size, the height does not increase as HTML increases.

The elements that are not absolutely positioned include blocks of the nearest block-level ancestors.
The same is true for floating elements, starting from the content boundary.

The absolute element is included by the nearest Position is not STATIC.

In fact, this is more complicated, and it is necessary to consider the absolute element containing blocks to be built or block-level elements. Inline case compatibility is relatively poor, so it is generally avoided to contain block-level elements in the inline elements, so most of them are created by block-level elements.
Its ContainiThe NG Block is formed by the inner boundary of the ancestral Border.

If the elements have attribute ‘Position: fixed’, Containing Block is created by the viewport

CSS picture CSS CSS picture level in two cases, sometimes the picture is required at the same time Vertical home,

The following is divided into several centers:

CSS picture level

1. Implement image level in the picture, using Margin: 0 Auto

】 Use margin: 0 auto to achieve picture in the picture, add CSS style margin: 0 auto as follows:

  
HTML text picture how vertical插图
2. Using the text level hidden attribute text-align: center

  
CSS picture vertical centered HTML text picture how vertical插图1
1. Using high == line high to implement picture vertical centered
This method is to indicate the height to use The code is as follows:

2. Implement the picture vertical centered
 Use the Table method to use Table's vertical home attribute, the code is as follows:  
Use Display: Table; and Display: Table-Cell; to simulate table, this method is not compatible with IE6 / IE7, IE67 does not support Display: Table, if you don't need to support IE67, you can use HTML text picture how vertical插图2
to disadvantage: When you set up display: table; may change your original layout

3. Using absolute positioning to implement picture vertical centrifugal

If known The width and height can be like this, the code is as follows:
  
HTML text picture how vertical插图1 4. The moving end can take the Flex layout Implement CSS picture vertical centrifugation
The mobile terminal general browser version is relatively high, so you can use the Flex layout, (Flex Layout Reference CSS3 Flex Layout) Demonstration code is as follows:
CSS Code:

.ui-flex {display: -webkit-box! Important; display: -webkit-flex! Important; display: -ms-flexbox! Important; display: flex! important; -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap} .ui-flex, .ui-flex *, .ui-flex: after, .ui-flex: before {box-zing: border-box} .ui-flex.justify-center {-webkit-box-pack: cenTer; -Webkit-Justify-Content: center; -ms-flex-pack: center; Justify-Content: center} .ui-flex.center {-Webkit-Box-Pack: center; -Webkit-Justify-Content: Center -MS-FLEX-PACK: CENTER; -WEBKIT-BOX-ALIGN: CENTER; -Webkit-Align-items: center; -ms-flex-align: center; align-items: center}

HTML code:
  
HTML text picture how vertical插图3

Thank you for reading! After reading the above, do you understand how the word picture of HTML is rid of? I hope that the content of the article will help everyone. If you want to know more about the content, please pay attention to Tumi Yun Industry Information Channel.


© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment