我有三个div标签,我想在div标签之间垂直留出空间,也希望将我的第一个div标签作为固定的。
当我将第一个div位置设置为非固定位置时,我可以留出垂直空间。
<html>
<head>
<title>div</title>
</head>
<body style="margin: 0; padding: 0;">
<div style="width:100%; background-color:Lime;">
<div style="width:100%; height:10%; background-color:Blue;">
a
</div>
<div style="width:70%; height:100%; background-color:Gray; margin: auto; margin-top: 2em; margin-bottom: 2em;">
b
</div>
<div style="width:100%; height:5%; background-color:Aqua;">
c
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
当我将“ div a”的位置更改为固定值时,“ div a”和“ div b”都从空白处下降:2em。
<html>
<head>
<title>div</title>
</head>
<body style="margin: 0; padding: 0;">
<div style="width:100%; background-color:Lime;">
<div style="width:100%; height:10%; background-color:Blue; position: fixed;">
a
</div>
<div style="width:70%; …
Run Code Online (Sandbox Code Playgroud) 我只想在存在“ needs_login”的情况下验证“ account_id”。我这样做:
$rules = [
'account_id' => ['required_with:needs_login','custom_validation']
];
Run Code Online (Sandbox Code Playgroud)
但这是行不通的,因为如果needs_login字段不存在,但account_id具有某些值,则它将尝试执行“ custom_validation”。我还尝试输入“有时”参数
$rules = [
'account_id' => ['required_with:needs_login', 'sometimes', 'custom_validation']
];
Run Code Online (Sandbox Code Playgroud)
但这没用。
有任何想法吗?
PS:请记住,我只想在有needs_login时才对account_id进行验证,而不是在需要Needs_login时才检查是否有account_id。