如何在导航栏中设置两个导航栏品牌图像?

时间:2018-11-08 14:38:13

标签: html css twitter-bootstrap twitter-bootstrap-3

我的应用程序中有导航栏,该导航栏应具有两个brand图像。一幅图像应该在最左侧,第二幅图像应该在右侧。到目前为止,我已经能够实现图像,但是我遇到的问题是固定高度和宽度。仅左侧图像显示正确。右侧的图像似乎在填充和尺寸方面存在问题。这是我当前代码的示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Test</title>
    <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <style type="text/css">
        .navbar-brand {
            padding: 0px;
        }
        .navbar-brand>img {
            height: 100%;
            padding: 5px;
            width: auto;
        }
    </style>
</head>
<body>
    <nav id="myNavbar" class="navbar navbar-default navbar-inverse navbar-fixed-top" role="navigation">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbarCollapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" data-toggle="tooltip" data-placement="top" title="Home Page" href="https://www.example.com" target="_blank"><img src="images/logo1.png" alt="Home"></a>
            </div>
            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="navbarCollapse">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#" target="_blank">Home</a></li>
                    <li><a href="#" target="_blank">About</a></li>
                    <li><a href="#" target="_blank">Contact</a></li>
                </ul>
                <ul class="nav navbar-nav navbar-right">
                    <li>
                        <a class="navbar-brand" href="#"><img src="images/logo2.jpg" alt="Image"></a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
    <div class="container">
        Main Content
    </div>
    <script language="javascript" type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script language="javascript" type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>

另一个问题是第二张图像将不会显示在xs尺寸的屏幕上。有解决这两个问题的好方法吗?

谢谢!

0 个答案:

没有答案