Problem:
We have a container element with % to define the width. In the container, we need to display another element that fullfills this container. The conained element need some border or padding. If we define the contained element's width to 100%, then the border and padding would make the contained element bigger than the container, because the actual width of the element would be the width+padding+border.
Solution:
Add a blocked element like <div> to wrap the contained element. Move the padding, margin or border of the contained element to the wrapper <div>. Set the contained element with width 100%, no border, margin, padding. The wrapper div will fullfill the outer container by the block feature.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
.container {
width: 30%;
height: 200px;
background-color: #adff2f;
padding: 10px;
}
.blocked_wrapper {
border: 1px solid #939598;
height: 20px;
}
.contained {
width: 100%;
height: 100%;
border: 0 none;
}
</style>
</head>
<body>
<div class="container">
<div class="blocked_wrapper">
<input type="text" class="contained"/>
</div>
</div>
</body>
</html>
Try it with jsfiddle
If you use CSS3, it would be much more easier. Border-box would completely solve this prblem.
.sizing {
padding: 0px 4px;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
-moz-box-sizing: border-box; /* Firefox, other Gecko */
box-sizing: border-box; /* Opera/IE 8+ */
}
Try it with jsfiddle
分享到:
相关推荐
关于Your page is blocked due to a security的解决方案
node-blocked, 检查事件循环是否已经被阻止 块检查 node 事件循环是否被阻止。如果运行 node.js ,你可以使用非常类似的阻止阻塞函数,从而使用非常类似的阻止阻塞函数。安装$ npm install blocked描述blocked() ...
Blocked
Checks blocked accounts in Active Directory
Webuser__AcWebuser__Access_any_blocked_website.pdf cess_any_blocked_website
The blocked_hash is used to find POSIX lock loops for deadlock detection. It is protected by blocked_lock_lock.
INDUCTION MOTOR TESTS (No-Load Test, Blocked Rotor Test)
blocked.certs
受阻# Cargo.tomlblocked = " ^0.1.1 " 被阻止者提供被blocked! 宏。 编译后,它将检查引用的问题是否已关闭,如果已关闭,则发出编译警告。 该宏采用问题模式和可选的“原因”。 找到BLOCKED_GITHUB_API_KEY环境...
Outlook add-in to unlock blocked attachments in .NET。
取决于php-lib-blocked-url(包括)和php5-curl。 我们还为l10n使用了polylang Wordpress插件,但这不是必需的。 在上测试插件 BlockedUrl 一个简单的库,可让您向其提交URL并在以后获取结果。 在Perl,PHP和...
milestones, tasks, blocked tasks, overdue tasks, time, expense
The Cache Performance and Optimizationof Blocked AlgorithmsMonica S. Lam, Edward E. Rothberg and Michael E. WolfComputer Systems LaboratoryStanford University, CA 94305AbstractBlocking is a well-known...
软件介绍: 本工具用于复制版本的DR4解锁重新使用,直接双击程序即可重新解锁使用资格,修复完成后请关闭插件的自动更新,并且不要点击检查更新。运行解锁工具后,需要重新打开PS--DR4----取消自动更新功能。
主要介绍了Oracle RAC环境下的阻塞(blocking blocked)介绍和实例演示本文提供了2个查询脚本,并给出实例演示那些session为阻塞者,哪些为被阻塞者,需要的朋友可以参考下
主要介绍了Oracle 阻塞(blocking blocked)介绍和实例演示,如何定位当前系统有哪些阻塞,到底谁是阻塞者,谁是被阻塞者,本文对此给出了描述并做了相关演示,需要的朋友可以参考下
iframe跨域问题:Uncaught DOMException Blocked a frame with origin解决方法
android-blocked-upload 安卓文件上传工具,公司内部需要使用文件上传,在github上搜索了一圈没有合适的,因此自己设计开发了此代码,清洗掉公司相关的信息后放到这里 实现原理: 使用java 的 RandomFileAccess 文件...
基于EFI的USB设备驱动的开发 可扩展固件接口(EFI)是英特尔提出的下一代BIOS的全新架构,将会逐步取代现有的BIOS。EFI提供了对USB设备的支持,用户无需进入操作系统,就可以使用USB设备。以USB设备驱动程序开发为例,描述...