好!欢迎访问迷津渡口 现在时间是: 天气 °C ~ °C

迷津渡口

越感到迷惑 越接近真理

css教程-input和img同行对齐

同一行的input和img总是对不齐,img比input高出那么点,烦人,最常见的是使用验证码的时候~

众所周知,水平对齐用text-align,这个属性非常常用,而且它有一个重要属性:继承性!

在使用垂直对齐vertical-align时,我们会以为它也是继承的,可惜不是哦!!!

因此同一行的input和img要想对齐,input和img都必须设置为vertical-align为middle。

实例试试吧:

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>input和img对齐 vertical-align</title>
	<style>
		* {
		    margin: 0px;
		    padding: 0px;
		    outline: none;
		}
		html, body {
		    font-family: "微软雅黑";
		    font-size: 16px;
		    width: 100%;
		    margin: 0px;
		    padding: 0px;
		    min-width: 780px;
		}
		.main {
		    margin: 0px auto;
		    height: 100%;
		    width: 780px;
		    padding-top: 60px;
		    /*外层设置垂直居中,但是不能继承,因此仍无法对齐*/
		    vertical-align: middle;
		}

		.main input,.main img {
			height: 36px;
    		line-height: 36px;
    		padding: 2px 4px;
    		padding-right: 30px;
    		width: 120px;
    		margin: 10px;
    		color: #666;
    		font-size: 14px;
		}
		.main img {
			border: 1px solid #000;
			padding-right: 4px;
			width:80px;
		}
		.main .verification2,.main .imgcode2 {
			/*两个都要设置垂直居中才能对齐*/
			vertical-align: middle;
		}
	</style>
</head>
<body>
	<div class="main">
		<form>
			<label for="verification1">没设置效果:</label><br/>
			<input class="verification1" type="text" name="verification1" placeholder="请输入验证码"/>
			<img class="imgcode1" alt="验证码" title="验证码" src="http://www.qingzz.cn/include/lib/checkcode.php"/>
			<br/>
			<label for="verification2">设置后效果:</label><br/>
			<input class="verification2" type="text" name="verification2" placeholder="请输入验证码"/>
			<img class="imgcode2" alt="验证码" title="验证码" src="http://www.qingzz.cn/include/lib/checkcode.php"/>
		</form>
	</div>
</body>
</html>


点赞1
   支持一下
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
 点赞
 签到
 表情
 图片
 代码
提交评论

清空信息
关闭评论
projetocidade
 projetocidade 2018-12-10 23:40回复
#15
<a href="http://www.eonkraftwerke.com/nike-free-3.0-womens-silver-blue-trainersf">nike free 3.0 womens silver blue</a> <a href="http://www.bisbeegrille.com/air-max-95-limited-edition-man-trainersb">air max 95 limited edition man</a> <a href="http://www.smsteachers.com/nike-air-huarache-herre-gr%C3%A5-shoesf">nike air huarache herre gr氓</a> <a href="http://www.relojesorion.com/elite-christian-hackenberg-youth-jersey-new-york-jets-5-road-white-nflc">elite christian hackenberg youth jersey new york jets 5 road white</a> <a href="http://www.gagnetoo.com/nike-foamposite-safari-bow-wow-shoesc">nike foamposite safari bow wow</a> <a href="http://www.synthcourses.com/parajumper-jacket-parajumpersr">parajumper jacket</a>
projetocidade http://www.projetocidade.com/
whitegayshop
 whitegayshop 2018-12-02 13:39回复
#14
<a href="http://www.lavantafilm.com/adidas-zx-flux-schwarz-and-rose-gold-dam%C3%A4nner-glasses-shoesv">adidas zx flux schwarz and rose gold dam盲nner glasses</a> <a href="http://www.floozyspeak.com/nike-air-max-shake-evolve-herre-guld-footd">nike air max shake evolve herre guld</a> <a href="http://www.newjerseycdl.com/nobis-stanford-vs-cartel-nobisr">nobis stanford vs cartel</a> <a href="http://www.issnederland.com/kobe-9-elite-shoesm">kobe 9 elite</a> <a href="http://www.ceespeters.com/air-max-thea-yellow-yarn-trainersa">air max thea yellow yarn</a> <a href="http://www.accsmonnaux.com/air-jordan-8-mens-white-silver-trainersf">air jordan 8 mens white silver</a>
[url=http://www.whitegayshop.com/]whitegayshop[/url]
jacdelaye
 jacdelaye 2018-11-30 08:00回复
#13
<a href="http://www.aberturasdh.com/asics-gel-noosa-tri-10-herre-gr%C3%A5-runningd">asics gel noosa tri 10 herre gr氓</a> <a href="http://www.jknets.com/adidas-zx-850-new-navy-issue-runninga">adidas zx 850 new navy issue</a> <a href="http://www.saeedlawyer.com/nike-free-1.0-womens-green-black-runningf">nike free 1.0 womens green black</a> <a href="http://www.hyaluronicset.com/kids-nike-air-max-bw-skox">kids nike air max bw</a> <a href="http://www.yupoji.com/jordan-12-pantone-low-skof">jordan 12 pantone low</a> <a href="http://www.thankhuc.com/harga-adidas-zx-flux-multicolor-shoesa">harga adidas zx flux multicolor</a>
jacdelaye http://www.jacdelaye.com/
brentography
 brentography 2018-11-28 12:52回复
#12
<a href="http://www.madamevelvet.com/billig-nike-hyperdunk-2014-low-menns-bl%C3%A5-trainersd">billig nike hyperdunk 2014 low menns bl氓</a> <a href="http://www.esmokecanada.com/grey-purple-mens-air-jordan-cp3-shoes-shoesg">grey purple mens air jordan cp3 shoes</a> <a href="http://www.chateaudefous.com/air-jordan-21-red-skox">air jordan 21 red</a> <a href="http://www.coldditch.com/nike-flyknit-boots-skor">nike flyknit boots</a> <a href="http://www.theblases.com/nike-air-max-one-khaki-sportsb">nike air max one khaki</a> <a href="http://www.acebelfast.com/mulberry-bayswater-large-mulberryr">mulberry bayswater large</a>
brentography http://www.brentography.com/
lukonsult
 lukonsult 2018-11-25 16:59回复
#11
<a href="http://www.femmedeguinee.com/atlanta-falcons-black-hat-hatr">atlanta falcons black hat</a> <a href="http://www.hollerrealtor.com/nike-womens-lunar-hyperdunk-basketball-shoes-sneakerg">nike womens lunar hyperdunk basketball shoes</a> <a href="http://www.psychedelicsf.com/air-jordan-10-womens-black-green-runningb">air jordan 10 womens black green</a> <a href="http://www.kristyhuston.com/puma-trinomic-blaze-of-glory-tech-black-skou">puma trinomic blaze of glory tech black</a> <a href="http://www.minruteguide.com/billig-nike-roshe-run-hyp-dam%C3%A4nner-wei%C3%9F-sportsa">billig nike roshe run hyp dam盲nner wei脽</a> <a href="http://www.dennygorman.com/nike-free-5.0-v2-orange-blue-yeti-skog">nike free 5.0 v2 orange blue yeti</a>
lukonsult http://www.lukonsult.com/
krzysztofkrol
 krzysztofkrol 2018-11-22 16:56回复
#10
<a href="http://www.eventyrklub.com/parajumpers-right-hand-parajumpersr">parajumpers right hand</a> <a href="http://www.paolamoney.com/michael-kors-hobo-bag-mkr">michael kors hobo bag</a> <a href="http://www.lumalend.com/adidas-zx-750-b39988-foote">adidas zx 750 b39988</a> <a href="http://www.interosells.com/billig-new-balance-1500-dam%C3%A4nner-blau-trainersce">billig new balance 1500 dam盲nner blau</a> <a href="http://www.prismbuffalo.com/pandora-princess-ring-sizes-pandorar">pandora princess ring sizes</a> <a href="http://www.nickebrown.com/flyknit-lunar-2-fit-urban-dictionary-sneakerf">flyknit lunar 2 fit urban dictionary</a>
krzysztofkrol http://www.krzysztofkrol.com/
goseecreate
 goseecreate 2018-11-22 15:18回复
#9
<a href="http://www.diveintovideo.com/adidas-springblade-ignite-hombres-verde-runningc">adidas springblade ignite hombres verde</a> <a href="http://www.moxiepouch.com/tory-burch-boots-with-fur-toryburchr">tory burch boots with fur</a> <a href="http://www.weissewelt.com/jordan-future-galaxy-jade-runningc">jordan future galaxy jade</a> <a href="http://www.rbengals.com/nike-air-huarache-nm-menns-gr%C3%B8nn-sneakerc">nike air huarache nm menns gr酶nn</a> <a href="http://www.onpointresale.com/air-jordan-8-white-black-sportsd">air jordan 8 white black</a> <a href="http://www.soaringcow.com/limited-terrance-west-jersey-cleveland-browns-20-road-white-nfle">limited terrance west jersey cleveland browns 20 road white</a>
goseecreate http://www.goseecreate.com/
grafiscar
 grafiscar 2018-11-21 22:02回复
#8
<a href="http://www.bonairecliffs.com/toddler-knit-beanie-hat-pattern-toddler-hatf">toddler knit beanie hat pattern toddler</a> <a href="http://www.maxfullforce.com/nike-free-trainer-v7-white-footc">nike free trainer v7 white</a> <a href="http://www.exomotors.com/nike-air-huarache-all-white-zombies-sportsf">nike air huarache all white zombies</a> <a href="http://www.missladymagic.com/new-balance-kids-shoes-skos">new balance kids shoes</a> <a href="http://www.avalonsoccer.com/bon-march%C3%A9-asics-gel-kinsei-2-femmes-or-footc">bon march茅 asics gel kinsei 2 femmes or</a> <a href="http://www.notbore.com/nike-flyknit-trainer-mens-gold-black-skod">nike flyknit trainer mens gold black</a>
grafiscar http://www.grafiscar.com/
lingatext
 lingatext 2018-11-20 02:47回复
#7
<a href="http://www.marijuanapier.com/lebron-12-low-final-game-trainersg">lebron 12 low final game</a> <a href="http://www.emazoncentral.com/oakley-frogskins-polished-white-ruby-iridium-sunglasses-directions-sunglassesb">oakley frogskins polished white ruby iridium sunglasses directions</a> <a href="http://www.pikespeakshop.com/nike-free-4-run-trainersg">nike free 4 run</a> <a href="http://www.lacosmeticink.com/bon-march%C3%A9-nike-chaussures-2017-femmes-violet-sneakerd">bon march茅 nike chaussures 2017 femmes violet</a> <a href="http://www.klgateslaw.com/adidas-nmd-runner-vapour-pink-light-onix-exclusive-zero-shoesv">adidas nmd runner vapour pink light onix exclusive zero</a> <a href="http://www.veronicaloman.com/nike-air-presto-flyknit-gold-blue-runningf">nike air presto flyknit gold blue</a>
bonodescuento
 bonodescuento 2018-11-17 04:23回复
#6
<a href="http://www.enescomert.com/adidas-neo-mesh-grey-purple-skoc">adidas neo mesh grey purple</a> <a href="http://www.iraqbody.com/%EF%BB%BFnikes-19-on-shoesm">锘縩ikes 19 on</a> <a href="http://www.eaudurable.com/zoom-pegasus-32-kids-foota">zoom pegasus 32 kids</a> <a href="http://www.chaiwanmei.com/womens-adidas-stan-smith-copper-white-kettle-trainersa">womens adidas stan smith copper white kettle</a> <a href="http://www.floornhome.com/difference-between-fake-and-real-ferragamo-belt-beltr">difference between fake and real ferragamo belt</a> <a href="http://www.jobmetry.com/adidas-kids-shoes-silver-pink-sportsb">adidas kids shoes silver pink</a>
bonodescuento http://www.bonodescuento.com/
顶部留言底部
 00:00/00:00
我想和你虚度时光 - 花房姑娘(9)
  1. 我想和你虚度时光
  2. 花房姑娘
  3. 恋恋风尘
  4. 我喜爱一切不彻底的事物
  5. 我的心里是满的
  6. Long Way
  7. 给少年的歌
  8. 晴日共剪窗
  9. 天上的月你的脸