简体   繁体   English

PHP代码中的CSS效果

[英]CSS effect inside PHP code

I have written some HTML code inside PHP with echo as below: 我在PHP中用echo编写了一些HTML代码,如下所示:

            echo '<a class = "fragment" href = "'.$row['url'].'" target = "_blank" >';
            echo '<div>';
            echo "Title: $title"; echo '<br/>';
            echo "URL:"; echo '<h4>' .$url. '</h4>';
            echo "Preview : $preview"; echo '<br/>';
            echo "Image url: $image"; echo '<br/>';
            echo '</br>';
            echo '</div>';
            echo '</a>';

Problem is $url appears on a new line and in bold text. 问题是$url以换行和粗体显示。 Though i have not used here <b> or <br/> before and after it. 尽管我之前和之后没有在这里使用<b><br/>

How can I show it like 我该如何显示

URL : www.url.com

same like other parameters appears? 像其他参数一样出现吗?

CSS effect appears properly. CSS效果正确显示。

css for h4: h4的CSS:

.fragment h4 
    {
        padding: 0;
        margin: 0;
        color: #000;
    }

    .fragment h4:hover 
    {
        background-color:#ccc;
        text-decoration: underline; 
    }

An h4 tag is (a) a heading tag (hence the boldness) and (b) a block-level tag (hence the new line). h4标签是(a)标题标签(因此为粗体)和(b)块级标签(因此为新行)。 If you don't want these aspects, why are you using it? 如果您不希望这些方面,为什么要使用它?

If you want to style this text, you should use the tag provided for the purpose: <span> . 如果要设置此文本的样式,则应使用为此目的提供的标签: <span> Give it a class or an id and style that. 给它一个class或一个id并设置样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM