图像不显示在表中

时间:2014-09-22 04:18:12

标签: html css

我正在进行作业,我需要在表格中放置一些图像,这对我来说通常不是问题。今天,当我将图像添加到表格时,它只显示一个方形边框,其中写有alt文本。我很确定我指向正确的目录。

我的文件夹结构是:

Website
  css
  fonts
  html (Page with table in here)
  js
  images (Images for table in here)

Table



@font-face{ font-family:customFont; src: url('../fonts/Balkeno.ttf'); }

* {
	margin: 0;
	border: 0;
	padding: 0;
	font-size: 12px;
	font-family: arial, sans-serif;
}

body {
	width: 100%;
	height: 300%;
	background-color: #D8D8D8;
}

nav {
	font-family: customFont;
	font-size: 30px;
	width: 100%;
	height: 40px;
	position: fixed;
	z-index: 50;
}

.nav-background {
	width: 100%;
	height: 100%;
	background: #12A7CB;
	opacity: 0;
	position: absolute;
}

.nav-content {
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}

header {
	width: 100%;
	height: 320px;
}

#slideshow {
    position:relative;
    height:320px;
	width: 100%;
}

#slideshow IMG {
    position:absolute;
    top:0;
    left:0;
    z-index:8;
	width: 100%;
	height: 320px;
	box-shadow: 0px 5px 10px #5E5E5E;
}

#slideshow IMG.active {
    z-index:10;
}

#slideshow IMG.last-active {
    z-index:9;
}

#logo { 
	float: left; 
	padding-left: 100px;
	padding-right: 200px;
}

#nav {
	background: url(http://4.bp.blogspot.com/-dVtgikk-kOY/UprtswP0yGI/AAAAAAAADag/Og0DtZ8t_oQ/s1600/header+base.png) no-repeat scroll top left;     background-color: transparent;
	width:100%;
	height:50px;
	box-shadow: 0px 1px 10px #5E5E5E;
	position:fixed;
	top:0px;
}

.title {
	display:none;
	color:#EDEDED;
	font-size:25px;
	width:350px;
	margin-top:6px;
	margin-left:150px;
	font-weight:bold;
	float:left;
}

.navigation li{
	list-style-image: url('navIcon.png'); 
	float: left;
	padding-right:45px;
	margin-bottom: 25px;
	color: black;
}

li {
	
}

.navigation a {
	font-size: 19px;
	font-family: customFont;
	text-decoration:none;
	color: #01ebfe;
} 

.navigation a:hover {
	
}

.wrapper {
	width: 900px;
	height: 1000%;
	margin-top: 25px;
	margin-left: auto;
	margin-right: auto;
	padding: 20px;
	background-color: white;
	padding-top: 100px;
	box-shadow: 10px 10px 5px #888888;
}

p{
	font-size: 14px;
	padding-bottom: 32px;
}

p:first-letter {
	font-size: 32px;
	color: #71CAE0;
}

h1 {
	font-family: customFont;
	font-size: 32px;
	font-weight: bolder;
	color: #12A7CB;
	text-align: center;
}

h2 {
	font-family: customFont;
	font-size: 22px;
	font-weight: bold;
	color: #12A7CB;
	text-align: left;
	text-decoration: underline;
}

section {
	width: 100%;
	height: 100%;
	background-color: #D8D8D8;
}

img.logo {
	text-align: center;
	margin: auto;
	display: block;
}

img.slideshow {
	width: 100%;
	height: 480px;
}

footer {
	width: 900px;
	margin: 25px auto 0 auto;
	padding-top: 20px;
	padding-left: 20px;
	padding-right: 20px;
	background-color: white;
	text-align: center;
	box-shadow: 10px 10px 5px #888888;
}

.members {
	padding: 10px;
	display: inline-block;
	background-color: #e4f4f8;
	margin-top: 15px;
	margin-left: 15px;
	border: 1px solid #12A7CB;
	float: right;
}

ol.test {
	list-style-type: lower-alpha;
}

.members ol {
	list-style-type: lower-alpha;
}

.members li {
	display: list-item;
	color: #6c6c6c;
	list-style-type: lower-alpha;
	padding: 5px;
	margin-bottom: 5px;
	margin-left: 10px;
}

/* TABLE STUFF */

table, tr, th, td {
	border: 1px solid black;
	border-collapse: collapse;
}

th {
	padding: 5px;
	color: #12A7CB;
	background-color: #e4f4f8;
}

td {
	background-color: #f2eded;
	width: 150px;
	height: 150px;
}

/* END TABLE STUFF */

.video-wrapper {
	width: 100%;
	text-align: center;
}

.video-wrapper a {
	color: blue;
	text-decoration: none;
	font-size: 12px;
	font-family: arial, sans-serif;
}

.social img {
	padding-top: 32px;
	padding-right: 8px;
	width: 48px;
	height: 48px;
	border: none;
}

<!DOCTYPE html>
<html>
	<!-- 
	Author: #####
	Date: 11/08/2014
	-->

	<head>
		<meta charset="utf-8" />
		<title>Home - Three Doors Down</title>
		
		<link rel="stylesheet" type="text/css" href="../css/style.css" /> 
		<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
		
		<script src="../js/jquery.js"></script>
		<script type="text/javascript" src="../js/scroll.js"></script>
		<script type="text/javascript" src="../js/header.js"></script>
		
	</head>
	
	<body>
		<nav class="nav">
			<div class="nav-background">
			</div>
			
			<div class="nav-content">
				<img src="../images/navTitle.png" alt="Three Doors Down" id="logo" width=250 />
				<ul class='navigation'>
					<li><a href="../index.html">Home</a></li>
					<li><a href="biography.html">Biography</a></li>
					<li><a href="discography.html">Discography</a></li>
					<li><a href="video.html">Video</a></li>
				</ul>
			</div>
		</nav>
		
		<header class="header">
			<div id="slideshow">
				<img src="../images/header1.jpg" alt="Three Doors Down" class="active" />
				<img src="../images/header2.jpg" alt="Three Doors Down" />
				<img src="../images/header3.jpg" alt="Three Doors Down" />
			</div>
		</header>
		
		<section>
			<div class="wrapper">
				<h1>Discography</h1>
				
				<div class="disco" >
					<table >
						<tr>
							<th>
								Album
							</th>
							<th>
								Year
							</th>
							<th>
								Record Label
							</th>
							<th>
								CD Cover
							</th>
						</tr>
						<tr>
							<td >
								The Better Life
							</td>
							<td>
							   2000
							</td>
							<td>
								Universal Republic
							</td>
							<td>
								<img href="../images/theBetterLifeCover.jpg" alt="The Better Life" width="100" height="100" />
							</td>
						</tr>
						<tr>
							<td >
								Away from the Sun
							</td>
							<td>
								2002
							</td>
							<td>
								Universal Republic
							</td>
							<td>
							   <image href="../images/awayFromTheSunCover.jpg" alt="Test" width="100" height="100" />
							</td>						
						</tr>
						<tr>
							<td >
								Seventeen Days
							</td>
							<td>
							   2005
							</td>
							<td>
								Universal Republic
							</td>
							<td>
								Cover
							</td>
						</tr>
						<tr>
							<td >
								3 Doors Down
							</td>
							<td>
							   2008
							</td>
							<td>
								Universal Republic
							</td>
							<td>
								<image />
							</td>
						</tr>
						<tr>
							<td >
								Time of My Life
							</td>
							<td>
							   2011
							</td>
							<td>
								Universal Republic
							</td>
							<td>
								Cover
							</td>
						</tr>					
					</table>
				</div>			
			</div>
		</section>
		
		<footer>			
			<div class="nav-content">
				<ul class='navigation'>
					<li><a href="../index.html">Home</a></li>
					<li><a href="biography.html">Biography</a></li>
					<li><a href="discography.html">Discography</a></li>
					<li><a href="video.html">Video</a></li>
				</ul>
			</div>
		</footer>
	</body>
</html>
&#13;
&#13;
&#13;

4 个答案:

答案 0 :(得分:1)

将href =“../ images / imageName.png”更改为src =“../ images / imageName.png”

答案 1 :(得分:1)

更改代码下面的代码......

<image href="../images/awayFromTheSunCover.jpg" alt="Test" width="100" height="100" />

新代码

<image src="../images/awayFromTheSunCover.jpg" alt="Test" width="100" height="100" /> 

href attr用于链接,即 a 标记。对于图像使用 src attr

答案 2 :(得分:0)

我检查了你的代码。您在HTML代码中提到的图片路径仅指向this链接。所以检查路径并确保图像在那里

答案 3 :(得分:0)

它&lt;&#; img src =&#34;&#34; &gt;,不是&lt; img href =&#34;&#34; &GT;