说,我得到了这个代码:
<figure>
<img src="bunnyrabbit.jpg" width="200" height="150" alt="An image of a bunny rabbit." />
<figcaption>Bunny rabits are cuddly and fluffy creatures with big ears. They eat carrots.</figcaption>
</figure>
Run Code Online (Sandbox Code Playgroud)
如果我不使用任何CSS,figcaption将扩展图元素的宽度超过200px.我怎么能阻止这个?
我知道我可以通过指定图元素(<figure style="width:200px;">)的宽度来强制figcaption中的文本换行,但我真的不想对每个图像使用它.
我有这个表格......
<form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>">
<fieldset>
<legend>Who are you?</legend>
<label for="first-name">First name</label><input type="text" name="first_name" required /><br />
<label for="last-name">Surname</label><input type="text" name="last_name" required /><br />
<label for="email">E-mail</label><input type="email" name="email" required /><br />
<input type="button" name="submit1" id="submit1" value="Next" />
<input type="button" name="clear" id="clear" value="Clear" />
</fieldset>
</form>
Run Code Online (Sandbox Code Playgroud)
有了这个CSS ......
form {
margin: 24px 0 0 0;
}
form legend {
font-size: 1.125em;
font-weight: bold;
}
form fieldset {
margin: 0 0 32px 0;
padding: 8px;
border: 1px solid #ccc;
} …Run Code Online (Sandbox Code Playgroud) 我有这个数组:
Array
(
[0] => Array
(
[id] => 1
[name] => tomato
)
[1] => Array
(
[id] => 2
[name] => carrot
)
[2] => Array
(
[id] => 3
[name] => apple
)
)
Run Code Online (Sandbox Code Playgroud)
我想在HTML表单中打印每个键/值对,如下所示:
<select>
<option value="1">tomato</option>
<option value="2">carrot</option>
<option value="3">apple</option>
</select>
Run Code Online (Sandbox Code Playgroud)
所以,我使用foreach循环迭代外部数组中的三个项目,然后尝试在一行中打印内部数组中的项目.我坚持到最后一点.我到目前为止最接近的是:
foreach ($food_opts as $key => $value) {
foreach ($value as $k => $v) {
echo '<pre>' . $v . '</pre>';
}
}
Run Code Online (Sandbox Code Playgroud)
这将检索我需要的数据,但不是以可用的格式:
1
tomato
2
carrot
3
apple
Run Code Online (Sandbox Code Playgroud)
简而言之,您如何定位内部数组中的单个项目?就像是:
foreach ($food_opts as …Run Code Online (Sandbox Code Playgroud)