gpt4 book ai didi

css - 文本将超出框(CSS 问题)

转载 作者:太空宇宙 更新时间:2023-11-03 18:29:17 25 4
gpt4 key购买 nike

我从 db 获取链接地址,它显示在带有 html h3 标签的 div 框中,类名是 .images。此 css 类图像宽度为 210px。但不幸的是,这个链接地址是在框外的。它应该在框内。你能告诉我我的 CSS 代码有什么问题吗?

CSS 代码:

.images{
max-width:210px;
float:left;
position:relative;
margin:15px 30px 15px 0;
border:0px #000 solid;
}
.images h3 a{width:210px !important; height:auto;}
.images img{
margin:0;
padding:5px;
border:1px #ccc solid;
}

照片代码:

while($res =  mysql_fetch_array($iamges)){

echo "<div class='images'>";

$image = $res['image'];
$directory = "galary_images/";
$link = inputvalid($res['link']);

echo "<h3><a href='$link' target='_new'>$link</a></h3>";

if(empty($link))
{
echo "<img src='$directory/$image'>";
}
else
{
echo "<a href='$link' target='_new'><img src='$directory/$image'></a>";

}
echo "</div>";
}

最佳答案

Since the link has no spaces in between, they cannot be broken into seperate lines. you can use code like this :
$link = "long link";
<a href = "long link">echo (strlen()<=10)?$link:substr($link, 0 ,7)."...";
</a>



Say link is http://stackoverflow.com/questions/20198005/text-is-going-to-outside-of-box-css-issue,
it will display something like this : http://stackoverflow.com on the name of the link but will send you to the same place.

关于css - 文本将超出框(CSS 问题),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20198005/

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