I'm using react-bootstrap and trying to add an icon to the NavBar
<Navbar.Header>
<Navbar.Brand>
<a href="#">☰ React-Bootstrap
<img src={logo} style={{width:100, marginTop: -7}} />
</a>
</Navbar.Brand>
<Navbar.Toggle />
</Navbar.Header>
However, the icon is not positioned properly in the navbar
And from the official site, i can't find any example of adding icon to the navbar.
Thanks
I think you will need to add a bit of CSS there.
.navbar-brand {
display: flex;
align-items: center;
}
.navbar-brand>img {
padding: 7px 14px;
}
Check working example on JSFiddle
Depending on your image size you can adjust it for your code
It's a dirty hack, but I had the same problem and added a className, 'nav-logo-' to my image and then did the following CSS:
.nav-logo {
float: left !important;
margin-top: -15px !important;
}
Related
For angular2 material project, the md-content is not available. There is no ETA when it's going to be available for use. Basically, I need a container with scrollable for overflow. What's the "material" way of doing this besides wrapper div and set overflow.
Angular2-drag-scroll is the library you are looking.
It is essentially a directive with overflow: scroll and other goodies
<style>
.demo-one {
height: 260px;
background-color: #FFFFFF;
}
.demo-one img {
height: 260px;
width: 260px;
margin-right: 10px;
}
</style>
<div drag-scroll drag-scroll-y-disabled="true" scrollbar-hidden="true" >
<img *ngFor="let image of imagelist" [src]="'assets/img/' + image" />
</div>
I'm applying "drag-scroll" to the div so everything in side of this div will be
draggable and has the attribute overflow: scroll etc.
Setting "drag-scroll-y-disabled" to true will disable y-axis scrolling/dragging.
Setting "scrollbar-hidden" to true will hide the scroll bar(ugly).
Github page: https://github.com/bfwg/angular2-drag-scroll
Demo site: https://bfwg.github.io/angular2-drag-scroll/
I have tried moving the id around and putting both first and second images as a backround. Why isn't it working?
HTML
<div class="brandsCarousel">
<ul>
<li class="logo"><img id="logo-gpjbaker"></li>
</ul>
</div>
CSS
a #logo-gpjbaker {
background-image: url(../images/logo-gpjbaker.png) center top no-repeat;
max-width: 150px;
}
a #logo-gpjbaker:hover {
background-image: url(../images/logo-gpjbaker2.png) center top no-repeat;
max-width: 150px;
}
The reason it it is not working is due to the space between your a and #logo-gpjbaker:hover
http://codepen.io/jonathan/pen/Jdaova
It should be, this with no space:
a#logo-gpjbaker:hover {
background: url(logo-gpjbaker2.png) center top no-repeat;
max-width: 150px;
display:block; /* add this */
height:50px; /* add this */
}
Since your id is on your anchor tag or just use #logo-gpjbaker:hover
Also try setting your a anchor tag to display:block so it fills the entire space of its parent. Which should be used anytime when using an anchor tag as a trigger since its default display is set to inline.
Don't forget to set your height property as well.
Try this
a#logo-gpjbaker:hover
or this
#logo-gpjbaker:hover
Here you have a better example: JSFIDDLE
How do I make it so that when I scroll down my sidebar stays in the same place
I have looked around but still can't find anything.
This is my code
<div class="example">
//stuff goes here
</div>
<style>
.example {
float: left;
background: blue;
width: 100px;
height: 100px;
}
</style>
Thanks in advance
.sidebar{
position:fixed;
right:0;
top:0;
}
I presume you want it to follow while scrolling?
I have a html document structured with a header, content, and footer divs. I am trying to center an image (a logo) inside my header div to display at the top of my webpage in the middle. I can absolute position it into the middle, but when I change the browser size, the img doesn't move along with it. I want it to be place automatically in the center of the window. I am stumped..?
I have tried , margin-right:auto; margin-left:auto. I have also tried the trick where you make margin-left negative half the width and top 50%, but nothing has worked so far.
html:
<body>
<div id="container">
<div id="header">
<img id="logo-img" src="http://f.cl.ly/items/3c0h1b0F3t1D1S1T2J0F/smallersticker.png">
</div>
/*...(body div)
...(footer div)*/
</div> /*container*/
css:
#header {
background-color:transparent;
height:260px;
width:100%
}
#logo-img{
display: block;
margin-left: auto;
margin-right: auto;
}
Also, Do I even need a container? Not sure if I need javascript for this, or if it can be accomplished with just html/css? Hope someone can help, thanks!
What is happening is that you are already correctly centering your image.
Your problem is that the image is huge. If you notice closely, the image is not centered if your browser window becomes smaller in width than the image.
Remove the white area from the image and it will center correctly.
Edit: in IE, you need to add the rule text-align:center to #header
Another way:
If you don't want to change your image, you can use this hack:
<style>
#header {
overflow-y: hidden;
background-color: transparent;
height: 260px;
width: 100%;
margin-left: 50%;
}
#logo-img{
display: block;
position: relative;
right: 50%;
}
</style>
<body>
<div id="container">
<div id="header">
<img id="logo-img" src="http://f.cl.ly/items/3c0h1b0F3t1D1S1T2J0F/smallersticker.png">
</div>
/*...(body div)
...(footer div)*/
</div> /*container*/
I learned this hack a while ago here
Just use the logo at a size it's supposed to be (like this here), then all you need to do is add the align="center" attribute to your logo's div.
For some odd reason I added a responsive image to my responsive layout and it seems to add some sort of spacing below the image.
You may view the issue here: http://www.client.noxinnovations.com/jensenblair/
The top image. Here is my HTML and CSS.
HTML
<div class="header"> <img src="images/photograph.jpg" /> </div>
CSS
img {
max-width: 100%;
height: auto !important;
}
.header {
height: auto;
padding: 0;
margin: 0 auto;
border: none;
}
It seems to be consistent in each browser. Any ideas anyone?
There are two ways (that I know of) to solve this: http://jsfiddle.net/3kC4K/1/
<div>
<img src="http://placehold.it/100x100/"/>
</div>
<div>
<img src="http://placehold.it/100x100/" class="block"/>
</div>
<div>
<img src="http://placehold.it/100x100/" class="inline"/>
</div>
CSS
div{
border:solid 1px #f00;
margin:5px;
float:left;
}
.block{
display:block;
}
.inline{
vertical-align:bottom;
}
img tags, by default, are inline elements. Because of this, browsers will create a sort of "gutter" underneath them so that any text that wraps below it won't be flush with the bottom of the image.
In your case, simply applying display:block to the image should do the trick.