我正在尝试将我的SVG徽标放在bootstrap的导航栏中,但由于某种原因,它不起作用.我试过用< object> (按照CSS Tricks的建议),内联svg和< img>,如下面的代码所示,但没有任何效果.
码
您可以保存SVG徽标以与< object>一起使用从Bootstrap’s site或download here.
#navigation { background-color: rgba(72,8,111,0.4); border: 0 none; margin: 0;}.navbar-brand { padding: 0;}.logo { margin: 0;}
<!DOCTYPE HTML><HTML lang="en"> <head> <Meta charset="utf-8"> <Meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1"> <Meta name="vIEwport" content="wIDth=device-wIDth,initial-scale=1"> <!-- Page Title --> <Title>svg on bootstrap's navbar</Title> <!-- CSS ================================================== --> <!-- Fontawesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/AJAX/libs/Font-awesome/4.7.0/CSS/Font-awesome.min.CSS"> <!-- Twitter bootstrap CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/AJAX/libs/twitter-bootstrap/3.3.7/CSS/bootstrap.min.CSS"> <!-- Main Stylesheet --> <link rel="stylesheet" href="main.CSS"> </head> <body ID="body"> <header ID="navigation" > <div > <div > <!-- responsive nav button --> <button type="button" data-toggle="collapse" data-target=".navbar-collapse"> <span >Toggle navigation</span> <i ></i> </button> <!-- end responsive nav button --> <!-- logo png --> <a href="#First"> <img src="http://i.imgur.com/qHjO7J9.png" alt="logo"> </a> <!-- end logo png --> <!-- logo object <a href="#First"> <object type="image/svg+xml" data="logo.svg" > logo </object> </a> end logo object --> <!-- logo inline svg <a href="#First"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" ID="Layer_1" x="0px" y="0px" vIEwBox="0 0 612 612" enable-background="new 0 0 612 612" xml:space="preserve"><g xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-Syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ID="solID" sodipodi:docname="twitter_bootstrap_logo.svg" inkscape:version="0.48.1 r9760"><path ID="bg" fill="#563D7C" d="M612 510c0 56.1-45.9 102-102 102H102C45.9 612 0 566.1 0 510V102C0 45.9 45.9 0 102 0h408c56.1 0 102 45.9 102 102V510z"/><g ID="B" enable-background="new "><path fill="#FFFFFF" d="M166.3 133h173.5c32 0 57.7 7.3 77 22s29 36.8 29 66.5c0 18-4.4 33.4-13.2 46.2 -8.8 12.8-21.4 22.8-37.8 29.8v1c22 4.7 38.7 15.1 50 31.2 11.3 16.2 17 36.4 17 60.8 0 14-2.5 27.1-7.5 39.2 -5 12.2-12.8 22.7-23.5 31.5s-24.3 15.8-41 21 -36.5 7.8-59.5 7.8h-164L166.3 133 166.3 133zM228.8 282.5h102c15 0 27.5-4.2 37.5-12.8s15-20.8 15-36.8c0-18-4.5-30.7-13.5-38s-22-11-39-11h-102L228.8 282.5 228.8 282.5zM228.8 439h110.5c19 0 33.8-4.9 44.2-14.8 10.5-9.8 15.8-23.8 15.8-41.8 0-17.7-5.2-31.2-15.8-40.8s-25.2-14.2-44.2-14.2H228.8V439z"/></g></g></svg> </a> end logo inline svg --> <!-- logo img svg <a href="#First"> <img src="logo.svg" alt="logo"> </a> end logo img svg --> </div> <!-- main nav --> <nav role="navigation"> <ul ID="nav" > <li ><a href="#First">First</a></li> <li><a href="#Second">Second</a></li> <li><a href="#Third">Third</a></li> <li><a href="#Forth">Forth</a></li> </ul> </nav> <!-- end main nav --> </div> </header> <section> <div > <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" ID="Layer_1" x="0px" y="0px" vIEwBox="0 0 612 612" enable-background="new 0 0 612 612" xml:space="preserve"><g xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-Syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ID="solID" sodipodi:docname="twitter_bootstrap_logo.svg" inkscape:version="0.48.1 r9760"><path ID="bg" fill="#563D7C" d="M612 510c0 56.1-45.9 102-102 102H102C45.9 612 0 566.1 0 510V102C0 45.9 45.9 0 102 0h408c56.1 0 102 45.9 102 102V510z"/><g ID="B" enable-background="new "><path fill="#FFFFFF" d="M166.3 133h173.5c32 0 57.7 7.3 77 22s29 36.8 29 66.5c0 18-4.4 33.4-13.2 46.2 -8.8 12.8-21.4 22.8-37.8 29.8v1c22 4.7 38.7 15.1 50 31.2 11.3 16.2 17 36.4 17 60.8 0 14-2.5 27.1-7.5 39.2 -5 12.2-12.8 22.7-23.5 31.5s-24.3 15.8-41 21 -36.5 7.8-59.5 7.8h-164L166.3 133 166.3 133zM228.8 282.5h102c15 0 27.5-4.2 37.5-12.8s15-20.8 15-36.8c0-18-4.5-30.7-13.5-38s-22-11-39-11h-102L228.8 282.5 228.8 282.5zM228.8 439h110.5c19 0 33.8-4.9 44.2-14.8 10.5-9.8 15.8-23.8 15.8-41.8 0-17.7-5.2-31.2-15.8-40.8s-25.2-14.2-44.2-14.2H228.8V439z"/></g></g></svg> </div> </section> <!-- jquery Plugins ================================================== --> <!-- Main jquery --> <script src="https://cdnjs.cloudflare.com/AJAX/libs/jquery/1.11.1/jquery.min.Js"></script> <!-- Twitter bootstrap --> <script src="https://cdnjs.cloudflare.com/AJAX/libs/twitter-bootstrap/3.3.7/Js/bootstrap.min.Js"></script> </body></HTML>
提前致谢,
路易斯.
#navigation { background-color: rgba(72,initial-scale=1"> <!-- Page Title --> <Title>svg on bootstrap's navbar</Title> <!-- CSS ================================================== --> <!-- Fontawesome --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/AJAX/libs/Font-awesome/4.7.0/CSS/Font-awesome.min.CSS"> <!-- Twitter bootstrap CSS --> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/AJAX/libs/twitter-bootstrap/3.3.7/CSS/bootstrap.min.CSS"> <!-- Main Stylesheet --> <link rel="stylesheet" href="main.CSS"> </head> <body ID="body"> <header ID="navigation" > <div > <div > <!-- responsive nav button --> <button type="button" data-toggle="collapse" data-target=".navbar-collapse"> <span >Toggle navigation</span> <i ></i> </button> <!-- end responsive nav button --> <!-- logo png --> <a href="#First"> <img src="http://i.imgur.com/qHjO7J9.png" alt="logo"> </a> <!-- end logo png --> <!-- logo object <a href="#First"> <object type="image/svg+xml" data="logo.svg" > logo </object> </a> end logo object --> <!-- logo inline svg <a href="#First"> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" ID="Layer_1" x="0px" y="0px" vIEwBox="0 0 612 612" enable-background="new 0 0 612 612" xml:space="preserve"><g xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-Syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ID="solID" sodipodi:docname="twitter_bootstrap_logo.svg" inkscape:version="0.48.1 r9760"><path ID="bg" fill="#563D7C" d="M612 510c0 56.1-45.9 102-102 102H102C45.9 612 0 566.1 0 510V102C0 45.9 45.9 0 102 0h408c56.1 0 102 45.9 102 102V510z"/><g ID="B" enable-background="new "><path fill="#FFFFFF" d="M166.3 133h173.5c32 0 57.7 7.3 77 22s29 36.8 29 66.5c0 18-4.4 33.4-13.2 46.2 -8.8 12.8-21.4 22.8-37.8 29.8v1c22 4.7 38.7 15.1 50 31.2 11.3 16.2 17 36.4 17 60.8 0 14-2.5 27.1-7.5 39.2 -5 12.2-12.8 22.7-23.5 31.5s-24.3 15.8-41 21 -36.5 7.8-59.5 7.8h-164L166.3 133 166.3 133zM228.8 282.5h102c15 0 27.5-4.2 37.5-12.8s15-20.8 15-36.8c0-18-4.5-30.7-13.5-38s-22-11-39-11h-102L228.8 282.5 228.8 282.5zM228.8 439h110.5c19 0 33.8-4.9 44.2-14.8 10.5-9.8 15.8-23.8 15.8-41.8 0-17.7-5.2-31.2-15.8-40.8s-25.2-14.2-44.2-14.2H228.8V439z"/></g></g></svg> </a> end logo inline svg --> <!-- logo img svg--> <a href="#First"> <img src="http://s.cdpn.io/3/kiwi.svg"> <!--img src="" alt="logo"--> </a> <!--end logo img svg --> </div> <!-- main nav --> <nav role="navigation"> <ul ID="nav" > <li ><a href="#First">First</a></li> <li><a href="#Second">Second</a></li> <li><a href="#Third">Third</a></li> <li><a href="#Forth">Forth</a></li> </ul> </nav> <!-- end main nav --> </div> </header> <!-- REMOVE THIS <section> <div > <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" ID="Layer_1" x="0px" y="0px" vIEwBox="0 0 612 612" enable-background="new 0 0 612 612" xml:space="preserve"><g xmlns:svg="http://www.w3.org/2000/svg" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-Syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" ID="solID" sodipodi:docname="twitter_bootstrap_logo.svg" inkscape:version="0.48.1 r9760"><path ID="bg" fill="#563D7C" d="M612 510c0 56.1-45.9 102-102 102H102C45.9 612 0 566.1 0 510V102C0 45.9 45.9 0 102 0h408c56.1 0 102 45.9 102 102V510z"/><g ID="B" enable-background="new "><path fill="#FFFFFF" d="M166.3 133h173.5c32 0 57.7 7.3 77 22s29 36.8 29 66.5c0 18-4.4 33.4-13.2 46.2 -8.8 12.8-21.4 22.8-37.8 29.8v1c22 4.7 38.7 15.1 50 31.2 11.3 16.2 17 36.4 17 60.8 0 14-2.5 27.1-7.5 39.2 -5 12.2-12.8 22.7-23.5 31.5s-24.3 15.8-41 21 -36.5 7.8-59.5 7.8h-164L166.3 133 166.3 133zM228.8 282.5h102c15 0 27.5-4.2 37.5-12.8s15-20.8 15-36.8c0-18-4.5-30.7-13.5-38s-22-11-39-11h-102L228.8 282.5 228.8 282.5zM228.8 439h110.5c19 0 33.8-4.9 44.2-14.8 10.5-9.8 15.8-23.8 15.8-41.8 0-17.7-5.2-31.2-15.8-40.8s-25.2-14.2-44.2-14.2H228.8V439z"/></g></g></svg> </div> </section> --> <!-- jquery Plugins ================================================== --> <!-- Main jquery --> <script src="https://cdnjs.cloudflare.com/AJAX/libs/jquery/1.11.1/jquery.min.Js"></script> <!-- Twitter bootstrap --> <script src="https://cdnjs.cloudflare.com/AJAX/libs/twitter-bootstrap/3.3.7/Js/bootstrap.min.Js"></script> </body></HTML>总结
以上是内存溢出为你收集整理的html – Bootstrap导航栏品牌中的SVG徽标全部内容,希望文章能够帮你解决html – Bootstrap导航栏品牌中的SVG徽标所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)