如何设置一个用echo写的链接的样式?

时间:2015-05-29 09:15:35

标签: php css

我想链接在div中是粗体,但是链接在一个用echo写下来的变量中。

<tr>
  <td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
  <div class="description">
    <b>Short description: </b></td>
</tr>
<tr>
    <td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
    <br>
      <?php print ($_SESSION['description']); ?><br>
    <br>
    <hr>
  </div>
  </td>
</tr>

该链接位于$_SESSION['description']。 css:

.description a:link {
    text-decoration: bold;
}

.description a:visited {
    text-decoration: bold;
}

.description a:hover {
    text-decoration: bold;
}

.description a:active {
    text-decoration: bold;
}

我已经尝试了一些方法,但风格&#34;无法看到&#34;用echo写的链接。我该如何解决这个问题?

3 个答案:

答案 0 :(得分:2)

<div class="description">
     <b>Short description: </b></td> </tr> <tr> ....

无效的HTML!

修复

  <tr>
    <td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">

   <b>Short description: </b></td>
  </tr>

  <tr>
    <td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
        <div class="description">    
          <br>
             <?php print ($_SESSION['description']); ?><br>
          <br>
          <hr>
        </div>
      </td>
    </tr>

答案 1 :(得分:0)

<a><?php echo $_SESSION['description']; ?></a>

现在它成为一个链接,你可以把样式放在

a:link{}

答案 2 :(得分:0)

全部替换

text-decoration: bold;

<强>与

font-weight:bold

<强>更新
一个downvote,认真?他将链接放在描述类中,只需要修复

现在样式可以看到(按照我的说法更换后)

<html>

<head>
  <style>
    .description a:link {
      font-weight: bold
    }
    .description a:visited {
      font-weight: bold
    }
    .description a:hover {
      font-weight: bold
    }
    .description a:active {
      font-weight: bold
    }
  </style>
</head>

<body>
  <tr>
    <td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
      <div class="description">
        <b>Short description: </b>
    </td>
  </tr>
  <tr>
    <td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
      <br>
      <a href="google.com">google</a>
      <br>
      <hr>
      </div>
    </td>
  </tr>

</body>
</head>

以及他在做什么

<html>

<head>
<style>
.description a:link {
    text-decoration: bold;
}

.description a:visited {
    text-decoration: bold;
}

.description a:hover {
    text-decoration: bold;
}

.description a:active {
    text-decoration: bold;
}
</style>
</head>
<body>
<tr>
  <td rowspan="1" colspan="4" style="vertical-align: top; width: 310px;" align="center">
  <div class="description">
    <b>Short description: </b></td>
</tr>
<tr>
    <td rowspan="1" colspan="4" style="vertical-align: top; height: 100px; width: 310px;" class="style2">
    <br>
     <a href = "google.com">google</a>
    <br>
    <hr>
  </div>
  </td>
</tr>

</body></head>

请在降级前检查