Discover how to make box centered in css, include the articles, news, trends, analysis and practical advice about how to make box centered in css on alibabacloud.com
css| Web page
One, with CSS to make the div layer horizontally centered
Add the following properties to the DIV layer that needs to be centered horizontally:
Margin-left:auto;Margin-right:auto;
This is already centered in FF, but
Core tip: use a pure CSS to achieve an unknown size of the picture (but width are less than 200px) in a 200px square container horizontally and vertically centered
In the past Taobao ued recruitment has such a topic:
"Use pure CSS to implement an unknown size picture (but width is less than 200px) centered horizontal
Long ago understand that when the element is fixed width and height, the horizontal vertical high Center method can set the negative value of the margin to the center, this negative value is half the width and height of the element, such as the width of the height is 100px, then use Margin-left:-50px;margin-top: -50px such a way of writing. But what if the width and height of this element are expressed as a percentage?If you use a percentage to set the width, the previous negative method has not
of the implementation of the horizontal center used to the last method, is to set the padding, so that the upper and lowerThe padding value is the same. Similarly, this is a "look" of the vertical center, it is only to make the text The code for the polygon:div {padding:25px;}The advantage of this approach is that it can be run on any browser, and the code is simple, but the premise of this approach is that the container's height must be scalable.div
Make CSS layouts more intuitive: box-sizingIf you've ever written CSS or you've been exposed to CSS, I'm sure you're not unfamiliar with the box model. One of the most confusing parts of CSS
, especially if you want to use a background image. It requires a combination of CSS Sprite technology (where different areas of the picture are used in different places) and sliding door technology (depending on the current size to display pictures of different lengths). Web Teaching Network
Let box level be extended
There is a simple way to make the
First, box models (box model)One box and 4 parts: Content,padding(fill),border(border), and margin(outer boundary)There are two types of box models:(1) standard box model(2) IE box model (content includes padding and border)In ord
Bubble dialog box in the Web page is often used to explain the features such as hints, you can vividly vivid reality some users need to pay attention to the text and content, this article describes the use of CSS only to achieve this simple web page effect.
Bubble-like text box, is a very vivid web design means.
It can be used to represent a user's speech.
It
%; margin-Top:-15px;}Html:DOCTYPE HTML>HTML> Head> Link rel= "stylesheet" type= "Text/css" href= "Maopao.css"> title>Testtitle> Head> Body> Div class= "Speech-bubble speech-bubble-top">Arrows at the top ofDiv> BR/> Div class= "Speech-bubble speech-bubble-bottom">Arrow at bottomDiv> BR/> Div class= "Speech-bubble speech-bubble-left">Arrow on the LeftDiv> BR/> Div class= "Speech-
Source: http://www.ido321.com/1214.htmlThe first two days translated an article about using CSS border properties to make Basic graphics: http://www.ido321.com/1200.htmlOn this basis. Share an article for everyone today. Suppose you make a bubble cue box with CSS.First look at 2 photos:Css:/*dialog BubblesHow to use: U
%; margin-Top:-15px;}Html:DOCTYPE HTML>HTML> Head> Link rel= "stylesheet" type= "Text/css" href= "Maopao.css"> title>Testtitle> Head> Body> Div class= "Speech-bubble speech-bubble-top">Arrows at the top ofDiv> BR/> Div class= "Speech-bubble speech-bubble-bottom">Arrow at bottomDiv> BR/> Div class= "Speech-bubble speech-bubble-left">Arrow on the LeftDiv> BR/> Div class= "Speech-
Css|yahoo
This article and the code by Renx original, copyright, casual use, which can be greatly seen in the next, useful to the words, I am honored you to tell me.BeginIn order to do this Yahoo search box, I divided three steps:1. To do the search category first button, click and other buttons will look different, this is quite simple
Of course, this is not enough, then realize the second step effect.
2.
Code: (The div and input must be continuously written together and cannot be wrapped)Divstyle= "font-size:36px;margin-top:30px">Divstyle= "Display:inline;background-color: #f9f9f9;p adding-left:5px;padding-right:5px;border:1px solid #aaa">-Div>inputtype= "Number"value= "1"readonly Style= "text-align:center;font-size:25px;height:45px;margin-top:-6px;width:100px;border-left:0px;border-right:0 px;border-bottom:1px Solid #aaa "/>Divstyle= "Display:inline;background-color: #f9f9f9; border:1px solid #
cannot float an element to a horizontally centered position, but there is a small tip (this article is no longer detailed and can be viewed by clicking on the link itself).code example:= + HTML code= CSS Codebody { background: #f06d06;}main { background: white; margin: 20px 0; padding: 10px;}.center { margin: 0 auto; width: 200px; background: black; padding: 20px; color: white;}=1.3 Two or more bl
The following code function is: No matter how long you enter a sentence, you can build the corresponding size box and the statement is centered in the box ...#!/usr/bin/envpython# definition sentence=raw_input ("sentence:") screen_with=80text_ Width=len (sentence) box_width=text_width+6left_margin= (screen_ with-text_width) //2# picture
, the initial effect: Pagination Navigation effect This is obviously not the effect we need, and then we'll make it in several ways:First, margin and width to achieve horizontal center The first method is the oldest implementation, is the most common solution, in the paging container to define a width, and then with the margin left and right values for the "auto" implementation effect: . pagination {width:293px;Margin-left:auto;Margin-right:auto;}. pa
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.