如何将btn btn-primary类添加到锚标记?

时间:2018-10-14 09:50:53

标签: html css

我想将btn btn-primary类添加到anchor taq 这是我的代码,但不起作用。

<ul class="pagination">
        <li><a class="btn btn-primary" href="?pageno=1" >First</a></li>
        <li class="<?php if($pageno <= 1){ echo 'disabled'; } ?>">
            <a href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>">Prev</a>
        </li>
        <li class="<?php if($pageno >= $total_pages){ echo 'disabled'; } ?>">
            <a href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>">Next</a>
        </li>
        <li><a href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
    </ul>

4 个答案:

答案 0 :(得分:1)

您可以尝试执行此操作:

<a href="?pageno=1">
    <button type="button" class="btn btn-primary">First</button>
</a>

答案 1 :(得分:1)

<head>标签内添加boostrap参考

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

答案 2 :(得分:0)

如果已从本地计算机添加了引导程序。然后您转到.btn-primary{color:#fff; background-color: #337ab7; border-color: #2e6da4;}。并搜索并替换此代码.btn-primary{color:#fff; background-color: #337ab7!important; border-color: #2e6da4!important;} 使用该代码,我相信它将对您有用。

public class BorderTest {

private JFrame jFrame;
private Container contentPane;
private ColorsBoard colorsBoard;

public BorderTest() {
    super();

    ToolTipManager.sharedInstance().setInitialDelay(10);
    ToolTipManager.sharedInstance().setDismissDelay(1500);
    jFrame = new JFrame();

    contentPane = jFrame.getContentPane();
    contentPane.setLayout(new BorderLayout());

    jFrame.setPreferredSize(new Dimension(700, 500));
    colorsBoard = new ColorsBoard();
    contentPane.add(colorsBoard, BorderLayout.CENTER);

    JLabel label = new JLabel(""
            + "<html>Click two or three small squares. <br/>"
            + "LineBorder's are set. <br/>"
            + "Then pass the tooltips over the red borders. <br/>"
            + "The red LineBorders' are back to blue. <br/>"
            + "This phenomen appears only in Metal L&F. </html>");
    contentPane.add(label, BorderLayout.EAST);

    jFrame.pack();
    jFrame.setVisible(true);
}

public static void main(String[] args) {
     try {
            UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");

        new BorderTest();
    } catch (Exception e) {
            e.printStackTrace();
    }
}
}

class ColorsBoard extends JPanel {

private int squareSize = 315;
private int horizontal = 8;    //number of squares H
private int vertical = 8;      //number of squares V

private SquaredPanel[] squarePanels;   
int index = 0;
public int lastClickedSquare = -1;

// the chess board like JPanel.

public ColorsBoard() {
    squarePanels= new SquaredPanel[horizontal * vertical];
    this.setPreferredSize(new Dimension(squareSize, squareSize));
    setLayout(null);
}

// fill with squares (SquaredPanel)

protected synchronized void paintComponent(Graphics g) {
    super.paintComponent(g);

    int tileSizeH = squareSize / horizontal;
    int tileSizeV = squareSize / vertical;

    g.setColor(Color.LIGHT_GRAY);
    g.fillRect(0, 0, getWidth(), getHeight());

    for(int i = 0; i < horizontal*vertical; i++) {
        squarePanels[i] = new SquaredPanel(this);
    }

    index = 0;
    for (int i = 0; i < horizontal; i++) {
        for (int j = 0; j < vertical; j++) {
                if(index == horizontal * vertical) break;
                    squarePanels[index].setBackground(Color.gray);
                    squarePanels[index].setSize(tileSizeH - 1, tileSizeV - 1);
                    squarePanels[index].setLocation(i * tileSizeH, j * tileSizeV);
                    squarePanels[index].setName("index " + index);
                    squarePanels[index].setIndex(index);
                    add(squarePanels[index]);
                    index++;
            }
        }
    }

public void eraseLastBlueBorder(int lastClickedSquare2) {
    if (lastClickedSquare == -1) {
        lastClickedSquare = lastClickedSquare2;
        return;
    }
    if(!squarePanels[lastClickedSquare].isRed)(squarePanels[lastClickedSquare]).cleanBorder();
    lastClickedSquare = lastClickedSquare2;
}
}

class SquaredPanel extends JPanel {

private String name;
protected Boolean isRed = false;
private int index;
private Border theBorder =  (new LineBorder(Color.gray, 2));

protected Border getTheBorder() {
    return theBorder;
}

public SquaredPanel(ColorsBoard colorsBoard) {
    super();

    addMouseListener(new MouseListener(){
        public void mouseClicked(MouseEvent e) {
        }
        public void mousePressed(MouseEvent e) {
        }
        public void mouseReleased(MouseEvent e) {
            colorsBoard.eraseLastBlueBorder(index);
            setTitleBorder("RED");
        }
        public void mouseEntered(MouseEvent e) {
            setToolTipText(name);
        }
        public void mouseExited(MouseEvent e) {
            setToolTipText(null);
        }
      });
}

// the setBorder call
    protected void setTitleBorder(String title) {
        theBorder = (new LineBorder(title == "BLUE" ? Color.red : Color.blue, 2));
        setBorder(theBorder);
    }


public synchronized void cleanBorder() {
    setTitleBorder("BLUE");
}

public void setName(String name) {
    this.name = name;
}

public void setIndex(int k) {
    index = k;
}
}

答案 3 :(得分:0)

以下是示例解决方案:

<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <title>Add Full Bootstrap</title>

   <!-- Latest compiled and minified CSS -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

   <!-- Optional theme -->
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css">
</head>    
<body>

<h1>Bootstrap Pagination</h1>

<ul class="pagination">
   <li><a class="btn btn-primary" href="?pageno=1">First</a></li>
   <li class="<?php if ($pageno <= 1) {
      echo 'disabled';
   } ?>">
      <a href="<?php if ($pageno <= 1) {
         echo '#';
      } else {
         echo "?pageno=" . ($pageno - 1);
      } ?>">Prev</a>
   </li>
   <li class="<?php if ($pageno >= $total_pages) {
      echo 'disabled';
   } ?>">
      <a href="<?php if ($pageno >= $total_pages) {
         echo '#';
      } else {
         echo "?pageno=" . ($pageno + 1);
      } ?>">Next</a>
   </li>
   <li><a href="?pageno=<?php echo $total_pages; ?>">Last</a></li>
</ul>

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>    
</html>

有关更多信息,请转到Getting started Bootstrap