Do you still remember the center we 've been tossing ?, Centered
Although the question of content center in div is already an old topic, many front-end developers have recently found that they are asking how to implement it. In fact, there are already a lot of materials and cases on the Internet. I will summarize several common solutions here.
Case 1: The div is limited to a height, and the content length is limited to one row.
1 .v-align {2 margin: 0 auto;3 width: 200px;4 height: 80px;5 text-align: center;6 line-height: 80px;7 border: 1px solid #ddd;8 }
1 <div class = "v-align"> my content can only have one row. </Div>
Case 2: The div is limited to a high level and the content is not limited.
1 .v-mult { 2 margin: 0 auto; 3 width: 200px; 4 height: 100px; 5 border: 1px solid #ddd; 6 overflow: hidden; 7 } 8 .v-mult .empty, 9 .v-mult .text {10 display: inline-block;11 *display: inline;12 *zoom: 1;13 vertical-align: middle;14 }15 .v-mult .empty {16 height: 100%;17 }
1 <div class = "v-mult"> 2 <span class = "empty"> </span> 3 <span class = "text"> my content is not limited, always high <br> line feed as usual </span> 4 </div>
Case 3: The div height is not fixed, and the content height is fixed.
1 .v-auto { 2 position: relative; 3 margin: 0 auto; 4 width: 200px; 5 border: 1px solid #ddd; 6 } 7 .v-auto .text { 8 position: absolute; 9 top: 50%;10 margin-top: -50px;11 height: 100px;12 border: 1px dashed #ddd;13 }
1 <div class = "v-auto"> 2 <div class = "text"> 3. My height is fixed and only 100px high, but my parent and height are not fixed, how can I center vertically? 4 </div> 5 <br> 6 </div>
Case 4: The div height is variable and the content height is variable.
1. v-auto-out {2 position: relative; 3 margin: 0 auto; 4 width: 200px; 5 border: 1px solid # ddd; 6} 7. v-auto-out. auto-in {8 position: absolute; 9 top: 50%; 10 border: 1px dashed # ddd; 11/* compatibility issues here */12-webkit-transform: translateY (-50%); 13-ms-transform: translateY (-50%); 14-o-transform: translateY (-50%); 15 transform: translateY (-50% ); 16}
1 <div class = "v-auto-out"> 2 <div class = "auto-in"> my height is variable, and my parent and height are also variable, what should I do if I want to center them up and down? Let's take a look. </Div> 3 <br> 4 </div>
Well, knowing these four methods is enough to cope with various vertical center problems in daily work. The code is very simple and I will not elaborate on it. In a word, each attribute style of CSS is like an organ of a human body. Only by understanding the functions of each organ can we complete various tasks together. On the contrary, individual abilities are limited.
Author blog: http://www.seejs.com
How does quick Bi center the page?
Do not minimize the horizontal width of the window.
In general, your monitor is too powerful.
What are the shortcut keys for word merge and center?
Is it common to merge cells? Is there a shortcut? What about the format brush, ascending and descending order, text alignment, cell fill color, font color, and so on? Obviously, these commonly used functions without shortcut keys are not very easy to use. Is there a way to change this situation? We know that in word processing software word, you can use a custom keyboard to specify shortcuts for Common commands. Can you do this in Excel? Let's take a look at the Excel custom dialog box. It is obviously different from the custom dialog box in Word. The Excel dialog box does not have the "keyboard" button, it seems that we cannot properly specify our own shortcut keys for common Excel functions. However, an accidental opportunity made me discover a secret-in the past, Excel could also customize your own shortcut keys. Are you eager to know the specific method? Well, let's take the merge center as an example. Let's talk about the specific operation process for adding shortcuts to the merge center: first, go to the "Custom" interface of Excel, select the "Custom" command from the "Tools" menu to open the custom dialog box. After the custom dialog box is opened, we will first let it stand by and ignore it. Find the "merge Center" button on the toolbar, right-click it, and click it. The system immediately displays a right-click menu, in the right-click menu, we can see menu meta-command items such as "Default style", "Always use only text", and "image and text. Now we can select the "image and text" menu item. The original "merge Center" button, which is short and cool, will become very large immediately. Besides the image, there is also a string of text-"merge and center (& M )". Now, we should close the custom dialog box to verify the effect. Do you want to close the custom? So what are our custom shortcuts? Yes, the shortcut key is not mentioned above. Let's mention it now. Select several cells in Excel, press the "Alt" key, and then press the "M" key. How can this problem be solved? Have you seen the results? Right, "Alt + M" is the quick way to merge and center-defined by yourself. So, since it is a self-defined shortcut key, can the key encoding be more casual without "Alt + M? Of course, the article is wonderful. You can take a look at it for a while. Let's go to the custom screen and right-click the "merge Center" button again, in the right-click menu, we find the "name" item. You can see the long name, that is, the name that makes the button very large. The key code is not changed but secondary, what should we change the name of a big bully, which occupies a very large place,? Let's keep "& M". Forget it, right. delete all the text except "& M". Now let's look at the merge center button. Is it much better? Next, we will also add a shortcut key for other commonly used buttons, such as the format brush, like the "merge Center" button, to customize the format brush button in the same step. After the definition, close the shortcut key for a try format brush in the Custom dialog box. Is it "Alt + F? As If yes, what is the effect after you press "Alt + F? Is the "file" menu selected? Yes, you have no eye disease. the File menu is selected. If you press "Alt + F" twice in a row, our format Brush tool will also be selected, and then press the Enter key to use the format Brush tool. Is this fast key too quick? It is better to extend your hand to the desktop, pick up the mouse, and use it to slowly click the button on the toolbar. Should I change the shortcut key? How can this problem be solved? Do we still remember the name of the merge center button? We also changed its name, that is, "& M, we can change "& M" to "& C" for a try. Is the shortcut key for merging and centering changed to "Alt + C? For the format Brush tool, we can change "& F" to "& M" Or something else. As long as there are no duplicates, your changes will succeed. So, if I don't want to change the format of "& F", I will change the file... the remaining full text>