#html #css #html5-canvas
#HTML #css #html5-холст
Вопрос:
Я пытаюсь выровнять правую часть изображения до нижней части тега div, используя css .up в моем теге style, но мне не повезло, чтобы получить iamge.Может ли кто-нибудь мне помочь, как я могу получить изображение с правой стороны снизу, используя margin
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
div.round1 {
border: 1px solid deepskyblue;
border-radius: 4px;
height: 170px;
width: 30%;
margin: auto;
}
.up {
margin-bottom: 350;
}
</style>
</head>
<body>
<div class="round1">
<table>
<tr>
<td>
<img src="https://placeholdit.imgix.net/~text?txtsize=12amp;txt=128×128amp;w=128amp;h=128" alt="Mountain1" style="width:128px;height:128px;">
<br>If a browser cannot find an image, it will display the alternate text
</td>
<td>
<img class="up" src="https://placeholdit.imgix.net/~text?txtsize=15amp;txt=138×70amp;w=138amp;h=70" style="width:138px;height:70px;">
</td>
</tr>
</table>
</div>
<br>
<div align="left">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">One</a>
</li>
<li><a data-toggle="tab" href="#menu1">Two</a>
</li>
<li><a data-toggle="tab" href="#menu1">Functional</a>
</li>
<li><a data-toggle="tab" href="#menu3">Three</a>
</li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>One</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Two</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
</div>
<div id="menu2" class="tab-pane fade">
<h3>Three</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
</div>
<div id="menu3" class="tab-pane fade">
<h3>Others</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
</div>
</div>
</div>
</div>
</body>
</html>
Комментарии:
1. Предоставьте ссылку на jsfiddle.
2. попробуйте указать
td
cssvertical-align:top
, который гарантирует, что содержимое будет начинаться в верхней частиtd
см. Здесь: w3schools.com/cssref/pr_pos_vertical-align.asp3. Я полагаю, что вам не хватает пикселей в поле margin-bottom.
Ответ №1:
вы забываете использовать px
Изменить свой код на:
.up {
margin-bottom:350**px**;
}
Ответ №2:
вы можете указать свой td
vertical-align:bottom
, который гарантирует, что правильное изображение всегда будет прилипать к нижней части, независимо от разницы в размерах
всегда лучше иметь динамическое решение
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
div.round1 {
border: 1px solid deepskyblue;
border-radius: 4px;
height: 170px;
width: 30%;
margin: auto;
}
td{ /*add this*/
vertical-align:bottom;
}
.up {
/*margin-bottom: 350; -- don't use both*/
}
</style>
</head>
<body>
<div class="round1">
<table>
<tr>
<td>
<img src="https://placeholdit.imgix.net/~text?txtsize=12amp;txt=128×128amp;w=128amp;h=128" alt="Mountain1" style="width:128px;height:128px;">
<br>If a browser cannot find an image, it will display the alternate text
</td>
<td>
<img class="up" src="https://placeholdit.imgix.net/~text?txtsize=15amp;txt=138×70amp;w=138amp;h=70" style="width:138px;height:70px;">
</td>
</tr>
</table>
</div>
<br>
<div align="left">
<div class="container">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">One</a>
</li>
<li><a data-toggle="tab" href="#menu1">Two</a>
</li>
<li><a data-toggle="tab" href="#menu1">Functional</a>
</li>
<li><a data-toggle="tab" href="#menu3">Three</a>
</li>
</ul>
<div class="tab-content">
<div id="home" class="tab-pane fade in active">
<h3>One</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text.</p>
</div>
<div id="menu1" class="tab-pane fade">
<h3>Two</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
</div>
<div id="menu2" class="tab-pane fade">
<h3>Three</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
</div>
<div id="menu3" class="tab-pane fade">
<h3>Others</h3>
<p>If a browser cannot find an image, it will display the alternate textIf a browser cannot find an image, it will display the alternate text</p>
</div>
</div>
</div>
</div>
</body>
</html>