Home Web Front-end HTML Tutorial Share an example tutorial on vertical centering of input text and button alignment issues

Share an example tutorial on vertical centering of input text and button alignment issues

Jun 24, 2017 am 11:31 AM
ie input vertical button letter

1. Box model problem: Please reset CSS

2. Buttons are not aligned: Please float or vertical -align:middle;Thencalculate the width and height to align them;

3. IE8 text is not centered : line-height attribute Note: IE8 does not support font writing (or a certain style does not support it)

The IE browser has been tested to IE8, use IE5, 6, and 7 with caution.

Cause of the problem: box model

1. Box model:

Put 2 inputs on the page, a text text box and a button button ( Set width and height without any other styles)

input[type='text']{width:400px;height:45px;}

input[type='button']{width: 45px;height:45px;}

Observation: IE8: Text box border:1px;padding:2px;

                                                                                                                                       . :Text box border:1px;padding:2px;

Button border:3px;padding:0px 8px;

Google: Text box border:2px;padding:1px 0px;

Button border:2px;padding:1px 6px;

Add style to make border and padding the same

input[type='text']{width:400px ;height:45px;border:1px solid red;padding:0;}

input[type='button']{width:45px;height:45px;border:1px solid red;padding:0;}

Observation:

IE8: Text box border:1px;content:202x47 (IE's box model)

Button border:1px;content:45x45 (IE's box model) )

Firefox: Text box border:1px;content:200x45

Button border:1px;content:43x43

Google: Text box border:1px;content:200x45

Button border:1px;content:43x43

2. Button alignment method: Floating

(The reason is that the Offset is different and I have not searched for more knowledge. You can supplement this aspect by yourself. Knowledge);input[type='text']{width:400px;height:45px;border:1px solid red;padding:0;float:left;}

input[type='button ']{width:45px;height:45px;border:1px solid red;padding:0;float:left;}


Refer to step 2,

Calculate the width and height by yourself and align them

(Some may not have border, use the background color instead, please set border:0; adjust the height yourself) input[type='text']{width:400px;height:45px;border:1px solid red; padding:0;float:left;}input[type='button']{width:47px;height:47px;border:1px solid red;padding:0;float:left;}

3. IE8 text centering: line-height Note: IE8 does not support font writing

Replace font:normal 18px "Microsoft Yahei"; with font-size:18px;font-style: normal;font-family:"Microsoft Yahei"!

Or (you can use font:normal 18px "Microsoft Yahei"; writing method, but it is not in the middle)

input[type='text']{width:400px;height:25px; padding:10px 0px;border:1px solid red;float:left;}

input[type='button']{width:47px;height:47px;line-height: 47px;border:1px solid red;padding: 0;float:left;}

The above is the detailed content of Share an example tutorial on vertical centering of input text and button alignment issues. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

5 Ways to Disable Delivery Optimization Service in Windows 5 Ways to Disable Delivery Optimization Service in Windows May 17, 2023 am 09:31 AM

There are many reasons why you might want to disable the Delivery Optimization service on your Windows computer. However, our readers complained about not knowing the correct steps to follow. This guide discusses how to disable the Delivery Optimization service in a few steps. To learn more about services, you may want to check out our How to open services.msc guide for more information. What does Delivery Optimization Service do? Delivery Optimization Service is an HTTP downloader with cloud hosting solution. It allows Windows devices to download Windows updates, upgrades, applications and other large package files from alternative sources. Additionally, it helps reduce bandwidth consumption by allowing multiple devices in a deployment to download these packages. In addition, Windo

How to make round pictures and text in ppt How to make round pictures and text in ppt Mar 26, 2024 am 10:23 AM

First, draw a circle in PPT, then insert a text box and enter text content. Finally, set the fill and outline of the text box to None to complete the production of circular pictures and text.

How to restart, force restart, and shut down iPad Mini 6 How to restart, force restart, and shut down iPad Mini 6 Apr 29, 2023 pm 12:19 PM

How to Force Restart iPad Mini 6 Force restarting iPad Mini 6 is done with a series of button presses, and it works like this: Press and release for Volume Up Press and release for Volume Down Press and release the Power/Lock button until you see Apple logo, indicating that the iPad Mini has been force restarted. That’s it. You have force restarted the iPad Mini 6! Force restart is usually used for troubleshooting reasons, such as the iPad Mini freezing, apps freezing, or some other general misbehavior. One thing to note about the procedure for force restarting the 6th generation iPad Mini is that for all other devices that have ultra-thin bezels and use

After rewriting:

How to Fix PS5 Controller Not Recognized on Windows 11 After rewriting: How to Fix PS5 Controller Not Recognized on Windows 11 May 09, 2023 pm 10:16 PM

<h3>What should I know about connecting my PS5 controller? </h3><p>As good as the DualSense controller is, there have been reports of the controller not connecting or not being detected. The easiest way to solve this problem is to connect the controller to your PC using an appropriate USB cable. </p><p>Some games natively support DualSense. In these cases, you can simply plug in the controller. But this raises other questions, like what if you don't have a USB cable or don't want to use one

How to add dots to text in word? How to add dots to text in word? Mar 19, 2024 pm 08:04 PM

When we create Word documents on a daily basis, we sometimes need to add dots under certain words in the document, especially when there are test questions. To highlight this part of the content, the editor will share with you the tips on how to add dots to text in Word. I hope it can help you. 1. Open a blank word document. 2. For example, add dots under the words "How to add dots to text". 3. We first select the words "How to add dots to text" with the left mouse button. Note that if you want to add dots to that word in the future, you must first use the left button of the mouse to select which word. Today we are adding dots to these words, so we have chosen several words. Select these words, right-click, and click Font in the pop-up function box. 4. Then something like this will appear

Change the power button action on Windows 11 [5 Tips] Change the power button action on Windows 11 [5 Tips] Sep 29, 2023 pm 11:29 PM

The power button can do more than shut down your PC, although this is the default action for desktop users. If you want to change the power button action in Windows 11, it's easier than you think! Keep in mind that the physical power button is different from the button in the Start menu, and the changes below won't affect the operation of the latter. Additionally, you'll find slightly different power options depending on whether it's a desktop or laptop. Why should you change the power button action in Windows 11? If you put your computer to sleep more often than you shut it down, changing the way your hardware power button (that is, the physical power button on your PC) behaves will do the trick. The same idea applies to sleep mode or simply turning off the display. Change Windows 11

How to use Vue to implement button countdown effects How to use Vue to implement button countdown effects Sep 21, 2023 pm 02:03 PM

How to use Vue to implement button countdown effects With the increasing popularity of web applications, we often need to use some dynamic effects to improve user experience when users interact with the page. Among them, the countdown effect of the button is a very common and practical effect. This article will introduce how to use the Vue framework to implement button countdown effects and give specific code examples. First, we need to create a Vue component that contains a button and countdown function. In Vue, a component is a reusable Vue instance, and a view will

iOS 17: How to organize iMessage apps in Messages iOS 17: How to organize iMessage apps in Messages Sep 18, 2023 pm 05:25 PM

In iOS 17, Apple not only added several new messaging features, but also tweaked the design of the Messages app to give it a cleaner look. All iMessage apps and tools, such as the camera and photo options, can now be accessed by tapping the "+" button above the keyboard and to the left of the text input field. Clicking the "+" button brings up a menu column with a default order of options. Starting from the top, there's camera, photos, stickers, cash (if available), audio, and location. At the very bottom is a "More" button, which when tapped will reveal any other installed messaging apps (you can also swipe up to reveal this hidden list). How to reorganize your iMessage app You can do this below

See all articles