开发者社区> 问答> 正文

jsp页面中如何把文字写在图片上想要的位置?

java webjavajspcss卡牌游戏
在.jsp页面中,我想把Lv写在图片左上角,球员位置写在右上角,人名写在图片左下角。但是现在文字位置不知道为什么有问题?应该怎么办?代码、图片如下。

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cards Page</title>
</head>

<body>

        <c:forEach items="${cardItems }" var="pci" varStatus="status">
            <div style="width: 139px; white-space: nowrap; float: left;">
            <a href="${pageContext.request.contextPath }/card/viewCardDetails/${pci.playerCardItemId }"><img style="border:2px solid white; position: relative;" alt="" src="<c:out value="${pageContext.request.contextPath }/${pci.playerCard.player.url }" />"></a>      
            <label  style="position: relative; top:-10px; left:-145px;"><font style="font-weight: bold;"><c:out value="${pci.playerCard.player.name }"></c:out></font></label>
            <label  style="position: relative; top:-170px; left:-135px;"><font style="font-weight: bold;"><c:out value="${pci.playerCard.player.position.abbreviation }"></c:out></font></label>
            <label  style="position: relative; top:-170px; left:-250px;"><font style="font-weight: bold;">Lv<c:out value="${pci.potentiality }"></c:out></font></label>
            </div>
        </c:forEach>
</body>
</html>

screenshot

展开
收起
蛮大人123 2016-03-19 14:19:07 6276 0
1 条回答
写回答
取消 提交回答
  • 我说我不帅他们就打我,还说我虚伪

    容器relative定位,label absolut定位

     <div style="width: 139px; white-space: nowrap; float: left;position:relative">
        <a href="${pageContext.request.contextPath }/card/viewCardDetails/${pci.playerCardItemId }"><img style="border:2px solid white; position: relative;" alt="" src="<c:out value=" ${pagecontext.request.contextpath } />${pci.playerCard.player.url }" />"></a>
        <label style="position:absolute; bottom:0px; left:0px;"><font style="font-weight: bold;"><c:out value="${pci.playerCard.player.name }"></c:out></font></label>
        <label style="position:absolute; top:0px; right:0px;"><font style="font-weight: bold;"><c:out value="${pci.playerCard.player.position.abbreviation }"></c:out></font></label>
        <label style="position:absolute; top:0px; left:0px;"><font style="font-weight: bold;">Lv<c:out value="${pci.potentiality }"></c:out></font></label>
    </div>
    2019-07-17 19:08:09
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载