您可以在下面的代码中看到,h1向下推动身体,绝对定位的块.absolute不会粘在顶部.但是你也可以看到同一个块粘在其父级的顶部.wrapper.为什么?
我不是在问这个伎俩; 我知道如何,例如填充而不是边缘到h1,或clearfix到父级等等.
我只对一件事情感兴趣:为什么h1保证金推低了body,但是没有推倒.wrapper?
body {
position: relative;
margin: 0;
padding: 0;
overflow: hidden;
background-color: silver;
}
.absolute {
position: absolute;
top: 0;
left: 0;
width: 50px;
height: 50px;
background-color: darkblue;
}
.wrapper {
position: relative;
overflow:hidden;
width: 50%;
height: 200px;
overflow: hidden;
background-color: yellow;
}
.wrapper > .absolute {
background-color: darkcyan;
}Run Code Online (Sandbox Code Playgroud)
<div class="absolute"></div>
<h1>Some title</h1>
<div class="wrapper">
<div class="absolute"></div>
<h1>Some title</h1>
</div>Run Code Online (Sandbox Code Playgroud)
好的,我会尽量更清楚.如果你点击下面的链接,你可以看到我的JSFiddle.有background-color: silver在 …
没有JS,有没有解决方案?
HTML
<div class="wrapper">
<div class="fix"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS
.wrapper {
max-width: 500px;
border: 1px solid red;
height: 5500px;
position: relative;
}
.fix {
width: inherit;
height: 20px;
position:fixed;
background: black;
}
Run Code Online (Sandbox Code Playgroud)
我不能添加任何其他样式.wrapper除外width: 100%;.我尝试width: inherit但它不适合我,因为我有父div只有最大宽度.资源
我需要使用自定义微调器创建输入类型="数字".它需要像那样
没有js我怎么能这样做?还是需要js?
对不起,我知道php太糟糕了.
我有php脚本将我的表单发送到我的电子邮件地址.
<?php
class Sendform {
private static $from_name = 'Mysite.com';
private static $from_email = 'mailer@Mysite.com';
private static $to_email = 'myemail@email.com';
public function send() {
$name = self::getvar('name');
$email = self::getvar('email');
$message = self::getvar('message');
$from_email = self::mime_encode(self::$from_name,"UTF-8")." <".self::$from_email.">";
$subject = 'subject';
$text = "Name: $name
E-mail: $email
Message: $message";
if($fileName) {
$un = strtoupper(uniqid(time()));
$head = "From: $from_email\n";
$head .= "To: ".self::$to_email."\n";
$head .= "Subject: ".self::mime_encode($subject,'UTF-8')."\n";
$head .= "X-Mailer: PHPMail Tool\n";
$head .= "Mime-Version: 1.0\n";
$head .= "Content-Type:multipart/mixed;";
$head .= …Run Code Online (Sandbox Code Playgroud)