My Custom CSS is causing any change in making the nav elements center with respect to the height of the navbar. Please Click on this text to see the image
Custom CSS code
you can just add !important beside your line-height number
example
.blabla {
line-height:70px !important;
}
Related
I am trying to include an image and some text inside a button element. My code is as follows:
<button class="testButton1"><img src="Car Blue.png" alt="">Car</button>
The CSS is:
.testButton1
{
font-size:100%;
height:10%;
width: 25%
}
.testButton1 img
{
height:80%;
vertical-align:middle;
}
What I would like to do is to position the image to the left edge of the button, and position the text either in the center or to the right. Using   works, but is perhaps a bit crude. I have tried to surround the image and text with spans or divs and then positioning those, but that seems to mess things up.
What appears to be happening is that anything inside the button tag (unless formatted) is positioned as one unit in the center of a wider button (not noticeable if button width is left to auto adjust as both items are side-by-side.
Any help, as always, is appreciated. Thank you.
Background Image Approach
You can use a background image and have full control over the image positioning.
Working example: http://jsfiddle.net/EFsU8/
BUTTON {
padding: 8px 8px 8px 32px;
font-family: Arial, Verdana;
background: #f0f0f0 url([url or base 64 data]);
background-position: 8px 8px;
background-repeat: no-repeat;
}
A slightly "prettier" example: http://jsfiddle.net/kLXaj/1/
And another example showing adjustments to the button based on the :hover and :active states.
Child Element Approach
The previous example would work with an INPUT[type="button"] as well as BUTTON. The BUTTON tag is allowed to contain markup and is intended for situations which require greater flexibility. After re-reading the original question, here are several more examples: http://jsfiddle.net/kLXaj/5/
This approach automatically repositions image/text based on the size of the button and provides more control over the internal layout of the button.
Change button display style to inline-block, img float to left. Add margin to img as necessary.
<button style="display:inline-block">
<img src="url" style="float:left;margin-right:0.5em">Caption
</button>
If you want to use image inside the button not in the CSS I think this help you:
http://jsfiddle.net/FaNpG/1/
Adding float left to the image works to an extent. A judicious use of padding and image sizing fixes the issue with having the text stuck to the top of the button. See this jsFiddle.
I'm working on a personal website template but I can't style the image and the text in the navbar.
I want to fix the aspect ratio of the image to center the navbar, so independently from the height of the navbar, the image will always look the same.
I want to center the text vertically
Make CONTACT into Contact
I'm not using boostrap or other frameworks.
You should check the flex box property, this is really useful. Here is some documentation on the subject and here is an example on how to build the layout you want using flex box.
1.- I didn't understand this one, you want to 'fix the ratio' but the ratio is already fixed and you can change the size of it using percentage on height and width.
2.- Add the next lines to the navbar css:
display: flex;
align-items: center;
that will center vertically all the elements in your navbar, including the image.
3.- Try this:
.navbar li:last-child a {
text-transform: lowercase;
}
or text-transform: capitalize if you want the first letter capitalized.
I'm a very noob CSS coder, but I would expect that if I add another line or a taller element in the navbar, making it higher, to push the body down. Instead it covers the top of the body, and I must increase padding on the body to push its top down below the navbar.
What CSS is at play here and why?
ProfK Hi there.
All you need to do here is add this css.
<style>
body {
padding-top: 50px;
}
</style>
And that will fix it for you.
Added to this
Here is a Fiddle this does what you are asking here.
What I do here is remove the padding-top or set it to zero.
I use a div to wrap the navbar and give this div a class of this-wrapand set the height to 50px the same as the height of the navbar.
Now what ever you place next in the body will be lower than the navbar and not under the navbar.
Does this help?... to act more as you expect.
I have all all my divs end with a space. This also affects the menu div which I do not want to have the additions padding at the end.
I tried to implement a NoEm style and use it, but of course it does nothing. As soon as I wrote it I relaised it would not affect the div. the code is here:
div {
margin-bottom: 1em; /* Adjust depending on your text's line-height */
}
div .NoEm {
}
So the question is:
How can I have ALL divs end with a margin except for one?
NO jquery or Js wanted.
EDIT: HTML
<div class="navbar navbar-inverse NoEm ">
EDIT: 2
JSFiddle
http://jsfiddle.net/jufb09m1/
COMMENT
Lol, so many down votes for not realising a CCS question required me to show a html markup of <div></div>
Set the margin-bottom for .NoEm
div {
margin-bottom: 1em; /* Adjust depending on your text's line-height */
}
.NoEm {
margin-bottom: 0;
}
IkoTikashi's answer is correct based on the information available when they posted it; before the fiddle was available.
Now that we can see your HTML code, we can see the additional problem: In addition to not explicitly setting the margin-bottom to 0 in your .NoEm class, your navbar div contains OTHER divs. All those divs also have a margin-bottom of 1em.
You need to use the fix IkoTikashi provided of explicitly setting margin-bottom in .NoEm to 0 and you need to use that class on all the divs used to create the navbar.
I am trying to include an image and some text inside a button element. My code is as follows:
<button class="testButton1"><img src="Car Blue.png" alt="">Car</button>
The CSS is:
.testButton1
{
font-size:100%;
height:10%;
width: 25%
}
.testButton1 img
{
height:80%;
vertical-align:middle;
}
What I would like to do is to position the image to the left edge of the button, and position the text either in the center or to the right. Using   works, but is perhaps a bit crude. I have tried to surround the image and text with spans or divs and then positioning those, but that seems to mess things up.
What appears to be happening is that anything inside the button tag (unless formatted) is positioned as one unit in the center of a wider button (not noticeable if button width is left to auto adjust as both items are side-by-side.
Any help, as always, is appreciated. Thank you.
Background Image Approach
You can use a background image and have full control over the image positioning.
Working example: http://jsfiddle.net/EFsU8/
BUTTON {
padding: 8px 8px 8px 32px;
font-family: Arial, Verdana;
background: #f0f0f0 url([url or base 64 data]);
background-position: 8px 8px;
background-repeat: no-repeat;
}
A slightly "prettier" example: http://jsfiddle.net/kLXaj/1/
And another example showing adjustments to the button based on the :hover and :active states.
Child Element Approach
The previous example would work with an INPUT[type="button"] as well as BUTTON. The BUTTON tag is allowed to contain markup and is intended for situations which require greater flexibility. After re-reading the original question, here are several more examples: http://jsfiddle.net/kLXaj/5/
This approach automatically repositions image/text based on the size of the button and provides more control over the internal layout of the button.
Change button display style to inline-block, img float to left. Add margin to img as necessary.
<button style="display:inline-block">
<img src="url" style="float:left;margin-right:0.5em">Caption
</button>
If you want to use image inside the button not in the CSS I think this help you:
http://jsfiddle.net/FaNpG/1/
Adding float left to the image works to an extent. A judicious use of padding and image sizing fixes the issue with having the text stuck to the top of the button. See this jsFiddle.