gpt4 book ai didi

php - 多彩多姿的div

转载 作者:行者123 更新时间:2023-12-03 03:05:03 24 4
gpt4 key购买 nike

我的网站是一个搜索引擎,它使用 foreach 循环返回许多结果,如下所示:

foreach ($xml->channel->item as $result) {
$ltitle = $result->title;
$ldesc = $result->description;
$url = $result->displayUrl;
$link = $result->link;

if (strlen($ltitle) > 60)
{
$title = substr($ltitle,0,60).'...' ;
}
else
{
$title = $ltitle;
}

if (strlen($ldesc) > 195)
{
$desc = substr($ldesc,0,195).'...' ;
}
else
{
$desc = $ldesc;
}


echo "

<br>


<div class='resultbox'>

<a class='normal' style='text-decoration:none;font-size:huge;font-weight:bold' href='$link'>$title</a><br>
<div style='padding-top:3px;padding-bottom:4px;width:580px;'>
<font style='text-decoration:none;font-size:small;font-family:Arial;'>$desc<br></font></div>
<a style='text-decoration:none;' href='$link'><font style='text-decoration:none;font-size:small;color:green;font-weight:bold;'>$url<br></font></a>

</div>
";
}

上面的 resultbox 类使用此样式设置所有结果

.resultbox
{
height:auto;
width:600px;
background-color:transparent;
font-size:19px;
padding:10px;
padding-left: 30px;
padding-right: 30px;
border-left: 6px solid #333;
}
.resultbox:hover
{
border-left: 8px solid #555;
}

左边框颜色是我想要改变的,我希望它从颜色代码列表中随机生成或样式化,这样结果就可以是#333 #555 #999,而不是全部#333等等......有什么想法吗?

最佳答案

如果你使用 JS 没有问题,你当然可以这样做:

$(document).ready(function () {

$('.resultbox').mouseenter(function() {
var randomColor = Math.floor(Math.random()*16777215).toString(16);
$('.resultbox').css("border-left", " 8px solid #"+randomColor);
});
});

关于php - 多彩多姿的div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16396601/

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