gpt4 book ai didi

jquery - 使用 html/css 将文本放在每个可点击图像的中心

转载 作者:行者123 更新时间:2023-11-28 11:49:24 25 4
gpt4 key购买 nike

我希望将一些文本置于可点击图像的中央。对于使用 HTML 和 CSS 将文本放在图像上的问题有很多支持,但我认为这些建议都不能解决我的问题。我认为这是因为我要执行此操作的 4 个图像没有固定位置,而是具有相对于窗口大小的大小。 This was particularly helpful, but for the J Query advice, the text didn't show up when I made the images clickable to links.

我意识到,由于图像会根据屏幕尺寸改变大小,我可能不得不使用 J-Query 将文本保留在图像中。如果您的想法超越了 HTML/CSS,我也很乐意这样做!

提前致谢一百万!!!

HTML:

<body>
<img class="logo" src="Logo1.png"/>
<div id="homeButtons">

<a href="livetv.html">
<img class="homeButtons" id="yellow" src="Content_Home/LiveTV.JPG"/>
TEXT
</a>

<a href="design.html">
<img class="homeButtons" id="blue" src="Content_Home/DandC.JPG"/>
</a>

<br>

<a href="resume.html">
<img class="homeButtons" id="green" src="Content_Home/Resume.JPG"/>
</a>

<a href="contact.html">
<img class="homeButtons" id="pink" src="Content_Home/Contact.JPG"/>
</a>

</div>
</body>

CSS:

    /* Standards for ALL Pages */

body{
background-color: black;
}

.logo{
width:100%;
}

.defaultFont{
font-size: 40px;
font-family: 'Montserrat', sans-serif;
color: yellow;
}

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

/* Home Page: home.html */

.homeButtons{
/* applies to squares individually */
width:30%;
border-radius: 20px;
opacity: .7;
margin: 10px;
}

#homeButtons{
/* centers all 4 squares as an entire entity, wouldn't work if was added to each individual square in the .homeButtons class above */
text-align: center;
display: inline-block;
}

#yellow{
border: 10px solid #FFE200;
}
#green{
border: 10px solid #00B400;
}
#blue{
border: 10px solid #006DF2;
}
#pink{
border: 10px solid #F2007D;
}

最佳答案

请在 Stackoverflow 上搜索类似的已解决问题,并尝试在它的帮助下是否可以解决问题。

这是一个类似问题的好答案 - Position text over image

这是来自 Chris Coyier 的精彩教程,用于实现图像上的文本

http://css-tricks.com/text-blocks-over-image/

希望对你有所帮助。

关于jquery - 使用 html/css 将文本放在每个可点击图像的中心,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20367966/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com