首页 > 解决方案 > PHP - aria-current 不显示

问题描述

对不起我的英语,我的PHP知识很差......

所以,我的问题.. 我有一个文件,heard.php有所有 PHP 代码,这里是我认为造成问题的 PHP 代码......

<nav class="link_wechsel">
 <ul>
  <li><a <?php if ($current_page=="1"): ?>aria-current="page" <?php endif ?> href="prove-1.php">1</a></li>
  <li><a <?php if ($current_page=="2"): ?>aria-current="page" <?php endif ?> href="prove-2.php">2</a></li>
  <li><a <?php if ($current_page=="3"): ?>aria-current="page" <?php endif ?> href="prove-3.php">3</a></li>
 </ul>
</nav>

这里是来自heard.php文件的所有代码;

<?php  
header("Content-Type: text/html; Charset=utf-8");
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
error_reporting(E_ALL);

?>

<!doctype html>
<html lang="en">
<head>
 <meta http-equiv="content-type" content="text/html; charset=UTF-8">
 <title>header-beispiel</title>
</head>
<style>
.link_wechsel ul {

  list-style-type: none;
  margin-left: 340px;
}

.link_wechsel li { display: inline; }

.link_wechsel a {

  display: inline;
  text-decoration: none;
  border: 1px solid gray;
  background-color: #FE2E64;
  color: black;
  padding: 8px;
  opacity: 0.5;
  font-family: Times New Roman;
}

.link_wechsel a:hover { background-color: #9f9e9e; }

.link_wechsel a.[aria-current=page] {

  background-color: green;
}

</style>
<body>
<header>
</header>
<nav class="link_wechsel">
  <ul>
   <li><a <?php if ($current_page=="1"): ?>aria-current="page" <?php endif ?> href="beispiel-1.php">1</a></li>
   <li><a <?php if ($current_page=="2"): ?>aria-current="page" <?php endif ?> href="beispiel-2.php">2</a></li>
   <li><a <?php if ($current_page=="3"): ?>aria-current="page" <?php endif ?> href="beispiel-3.php">3</a></li>
  </ul>
 </nav>
</body>
</html>

比我有三个显示此代码的文件,Prove-1.php,Prove-2.php 和 Prove-3.php,这里是代码;

<?php  
$current_page = "1";
require 'header.php';

header("Content-Type: text/html; Charset=utf-8");
mb_internal_encoding('UTF-8');
date_default_timezone_set('UTC');
error_reporting(E_ALL);
?>

<!doctype html>
<html lang="en">

<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
 <title>prove-1</title>
</head>
<body>
 <h3>Page 1</h3>
</body>
</html>

在所有三个文件上我都有相同的 Code ,只是改变 $ current_page = "1"; , $current_page = "2"; $current_page = "3"; ..如何查看页面的屏幕截图,在这里..

如您所见,当前选择的页码的颜色没有变化。

CSS代码,就是说它......

.link_wechsel a.[aria-current=page] { background-color: green; }

可以请任何人帮助我并从我的问题中找到解决方案,谢谢!

标签: phphtmlcss

解决方案


我发现问题是因为当前选择的页码颜色没有变化。

那个问题出在 CSS 上。

我写,

.link_wechsel a.[aria-current=page] { background-color: green; }

当我想做的时候

.link_wechsel a[aria-current=page] { background-color: green; }

without the Point after a . Because aria-current is a attribute and page its Value , therefore the a tag , not need a Point . How to see now without Point...


推荐阅读