CSS: What makes one extend box in all directions?

Source: Internet
Author: User
Tags extend

http://www.webdesignerwall.com/tutorials/css-the-all-expandable-box/ Web Teaching Network

In HTML, if you don't specify a certain width, the block-level element itself is stretched vertically. Imagine an unordered list. The list expands itself to accommodate all of its manifest elements. If the user adds a font size to their browser, the list is stretched vertically to accommodate the larger content. Sometimes it's very limited to feel just stretching vertically, and it's even better if the horizontal direction is as vertical as the user can increase the font size.

Profile

If you have used Firefox 3 beta, you will find that it has been automatically handled this way. Increasing the size in Firefox 3 is more than just increasing the font size. It increases the size of all elements. This looks very natural and beautiful. But while Firefox's market share is rising, we can't expect Firefox to resize to meet user needs.

I try to explain how to make a party that has the following characteristics to extend box:

Able to work in all major browsers.
Extend in both vertical and horizontal directions.
Use a separate background picture.

This is a bit demanding, 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 box level extendable: Use EM to define your width. For example :

. box {
Width:35em;
margin:50px Auto;
Web Teaching Network

The margin attribute here is just for example, to center it horizontally and always have a certain distance from the top of the browser. Web Teaching Network

Thinking about picture positioning

In this case, this is a rounded box with a bit of projection and a bit of internal shading. This means that the four corners of the box are obviously different. The challenge here is that the picture cannot be extended. We need a way to get four different fillet images to be applied to the box's Four corners, respectively. . Com

We also need to engage them to make the transition no clear line, and we have to try to use a background image to make it as effective as possible. . Com

Here is a map of what you care about what we need to do, box will be spliced, I'll separate them, and you'll see all the box.

Web Teaching Network

When creating a background image, consider the size, the larger your background picture, the larger you can extend without destroying the layout. The background in the example is 700 pixel wide and it can work in 4-5 font sizes. But if it exceeds this size, it will eventually depart.

Writing box

Of course, we want to use XHTML to achieve as much semantic as possible. This means that you cannot use extra content that is not intended to be used solely for the design of the label. Unfortunately, when you use four box to stitch a box, there's no way to do it. . Com

It is done in this way:. Com





CONTENT GOES Here






Set style for box

This is the four areas in box:. Com

.box div.topleft {
 display:block;
 background:url ("Images/box-bg.png") top left no-repeat white;
 padding:2.0em 0em 0em 2.0em;
} Web page teaching network

.box div.topright {
 display:block;
 background:url ("Images/box-bg.png") top right no-repeat white;
 padding:2.0em;
 margin: -2.0em 0 0 2.0em;
} . Com

.box div.bottomleft {
 display:block;
 height:45px;
 margin-top: -2.0em;
 background:url ("Images/box-bg.png") bottom left no-repeat white;
} . Com

.box div.bottomright {
 display:block;
 background:url ("images/box-bg.png") bottom right no-repeat white;
 height:45px;
 margin-left:3.0em;
}

Note that a negative outer patch is the necessary way to fill in the inner patch values applied to the parent element. It can be a good solution to the use of the internal patch method. Keep the text inside the box, and notice that I've defined the height of the bottom div in pixels to keep them short and not to stretch.



Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.