2017-07-24 74 views
-1

我试图使用CSS和HTML来获取“这个文字在底部图像的中心,但是不管我尝试什么,它都不会移动。和CSS。文字不会移动到图像上

<table> 
    <th><a href="#home">Home</a>&nbsp </th> 
    <th><a href="#catalog">Catalog</a>&nbsp </th> 
    <th id="Unique"><a href="#specials">Specials</a>&nbsp </th> 
    <th><a href="#contact">Contact Us</a>&nbsp </th> 
    <th><a href="#about">About Us</a>&nbsp </th> 
    <th><a href="#signin">Sign In</a>&nbsp </th> 
    <th><img src=" cart.png" height="20" width="20" href="www.google.com" /> </ th> 

</table> 
<div class="hoverinfo"> 

    <p> 
    <a href="www.google.com" class="one">Power User</a></p> 

</div> 
<a href="www.google.com" class="two"> 
    <font color="blue">This </font> 
</a> 

<img src="both.jpg" style="float: left; width: 100%; height: 100%;margin-right: 1%; margin-bottom: 0.5em;"> 




<p style="clear: both;"> 
+1

你忘了,包括你的CSS。我将您发布的代码放入可更新的代码片段中。 – j08691

回答

0

我觉得这是你所要求的东西。我加CSS到一个div容器。它所做的是文本对齐中心。

.two-con { 
 
    text-align: center; 
 
}
<table> 
 
    <th><a href="#home">Home</a>&nbsp </th> 
 
    <th><a href="#catalog">Catalog</a>&nbsp </th> 
 
    <th id="Unique"><a href="#specials">Specials</a>&nbsp </th> 
 
    <th><a href="#contact">Contact Us</a>&nbsp </th> 
 
    <th><a href="#about">About Us</a>&nbsp </th> 
 
    <th><a href="#signin">Sign In</a>&nbsp </th> 
 
    <th><img src=" cart.png" height="20" width="20" href="www.google.com" /> </ th> 
 

 
</table> 
 
<div class="hoverinfo"> 
 

 
    <p> 
 
    <a href="www.google.com" class="one">Power User</a></p> 
 

 
</div> 
 

 
<div class="two-con"> 
 
    <a href="www.google.com" class="two"> 
 
    <font color="blue">This </font> 
 
    </a> 
 
</div> 
 

 
<img src="both.jpg" style="float: left; width: 100%; height: 100%;margin-right: 1%; margin-bottom: 0.5em;"> 
 

 

 

 

 
<p style="clear: both;">

CSS:

a:hover{ 
color: red; 

} 
a { 
text-decoration: none; 
color: white; 
} 

table{ 

border-color: black; 
height: 30px; 
width: 100%; 
background-color: black; 
border-radius: 5px; 
color: white; 
} 

#Unique{ 
    background-color: #D4AF37; 
    border-radius: 5px; 

} 

.hoverinfo { 
position: absolute; 
top: 330px; 
left: 565px; 
bottom: 100px; 
font-size: 36px; 
font-family: cursive; 
color: black; 
cursor: pointer; 

.hoverinfo p { 
display: none; 
color: black; 
} 

.hoverinfo:hover p { 
background-color: yellow; 
display: block; 
color: black; 
} 

.two { 
position:absolute; 
text-align:center; 
top:500px; 
left:596px; 

bottom: 100px; 
font-size: 56px; 
font-family: cursive; 
color: black; 
cursor: pointer; 

.two p { 
display: block; 

color: black; 

} 

.two:hover p { 
background-color: yellow; 
display: block; 
color: black; 
} 
+0

谢谢,唯一的问题是左上角的“this”不会移动 – Daniel