I have such HTML:
<div class="select-wrapper">
<select name="type">
<option value="test">test</option>
</select>
</div>
And css:
#search-box .select-wrapper {
display: inline-block;
padding: 6px;
background: #eaeced;
}
#search-box select {
font-size: 11px;
margin: 0px;
padding: 0px;
padding-left: 8px;
border: 1px solid #a6a6a6;
-webkit-border-radius:2px;
-moz-border-radius:2px;
-border-radius:2px;
}
However somehow wrappers top padding is bigger then bottom one:
When I highlight wrapper in inspector, it looks like that:
As you can see, there is some space between selects top border and top of the inner content of a wrapping div.
Why is it there ? How can I force both top and bottom spacing to be equal ? I need that wrapping element for additional outer border.
CSS outline and box-shadow isn't enough, because I need to specify corner rounding. Shadows rounding is relative to border rounding and its too big for me, so I need to make this outer border with DIV-wrapper with my own, small border-radius.
The height of the select is smaller than the inner height of .select-wrapper.
Add display: block and height: 100% to the select so it will take the full height and width of it's parent.
DEMO.
You could change the font size to 100%, although it changes the font size from what you originally coded, it does sort the padding outside of the select box.
#search-box select { font-size:100%; }
http://jsfiddle.net/r2wpxvw2/
http://jsfiddle.net/sj1aL1o8/
.select-wrapper {
display: inline-block;
padding: 6px;
background: #eaeced;
line-height: 16px;
}
Related
I have a simple grid with 2 columns with border and two columns Fiddle
The problem is I want to adjust the border to the content and the content has left padding, so I want to remove that free space.
I tried to use box-sizing: border-box; but it causes no effect
HTML:
<div class="totalContainer totalContainer__space" *ngIf="selectedMenuItem === menu[3]">
<div class="totalContainer__text">
<label><strong>Annual</strong> Test Test </label>
</div>
<div class="totalContainer__text totalContainer__result">
<label><strong>80</strong></label>
</div>
</div>
SCSS:
.totalContainer {
display: grid;
grid-template-columns: 2fr 1fr;
margin-top: 30px;
border: 1px solid rgba(72, 82, 93, 0.8);
border-radius: 12px;
box-sizing: border-box;
&__row {
background-color: #E5E5E5;
}
&__space {
padding: 10px 0 10px 140px;
}
&__text {
font-size: 13px;
}
&__result {
text-align: right;
}
}
Using margin-left instead of padding:
&__space {
padding: 10px 0 10px 10px;
margin-left: 140px;
}
I think you are missing the big picture here.
Making up a block box in CSS we have the:
Content box: The area where your content is displayed, which can be
sized using properties like width and height. Padding box: The padding
sits around the content as white space; its size can be controlled
using padding and related properties.
Border box: The border box wraps
the content and any padding. Its size and style can be controlled
using border and related properties.
Margin box: The margin is the
outermost layer, wrapping the content, padding, and border as
whitespace between this box and other elements. Its size can be
controlled using margin and related properties.
So in short the border includes the padding (it wraps the content as well as the padding), while the margin lays outside of it (pushing the content with border and padding included). I would recomand to check the box model docs.
I have the following part of my html
<div class="header">
<div class="header-bar">
<div class="pull-left">
<div class="title">Ci models database</div>
</div>
</div>
<div class="clear-both"></div>
<ol class=breadcrumb>
<li class="active">All models</li>
</ol>
</div>
the css(breadcrumb and active classes are bootstrap)
.header-bar {
border: None;
background-color: #66CCFF;
min-height:30px;
}
.title {
padding: 5px 5px 10px 5px;
color: white;
font-size: large;
}
.clear-both{
clear:both;
}
But between header-bar and breadcrumb html added a white space(see bootply). How can I remove this white space, since no padding and margin can be found between to divs.
The problem is that the calculated height of the internal .title div is greater than the calculated height of the container .header-bar. Properties like height, min-height, border, padding can directly effect heights, whereas properties like display, box-sizing and position can all indirectly effect height.
The result is the internal .title div pushes down the next div in the flow by 10px.
CSS has no rules that say a div must contain it's children in height and stop them from effecting other divs, even when height is directly defined. We need to tell it exactly how it should behave when things are rendered.
There are several ways to fix this:
http://www.bootply.com/Qa1ME2M2uk - use overflow: hidden; on the parent. Overflow is a css property which is used how to control what happens when child elements are larger than their parents. It's worth noting that depending on other properties overflow won't necessarily render itself in a way that disrupts layout.
http://www.bootply.com/ssq3EAzeyk - set explicit heights to take strict control over the dimensions of the elements. This might be the best option for a header bar.
http://www.bootply.com/yeodYRLLJk - set a greater min-height on the parent, one which will definitely contain the child. This is useful if your padding is for alignment purposes - setting min-height: 40px; in the example does this.
http://www.bootply.com/GznfJxUWUF - remove the padding that is making the element calculate as taller (as mentioned in another answer).
Apostolos, the white space is coming from the .titleclass.
The bottom padding of 10px.
Zero this and the white space will go.
.title {
padding: 5px 5px 0px 5px;
you will have to add a float: left to both parent containers (.header-bar and breadcrumb) otherwise the clear won't affect anything. furthermore you will have to give both containers width: 100%
.header-bar {
border: None;
background-color: #66CCFF;
min-height:30px;
width: 100%;
float: left;
}
.breadcrumb {
width: 100%;
float: left;
}
.title {
padding: 5px 5px 10px 5px;
color: white;
font-size: large;
}
.clear-both{
clear:both;
}
I have a simple set of links at the top of a page with a black border underneath. The active link should show a white border underneath. This border should sit directly over the black border.
I am unable to change the HTML at this stage, only the styling.
Here is a fiddle - http://jsfiddle.net/grimmus/8E4D5/
<div class="c-landing-pg-tabs-container">
<div class="c-landing-pg-tabs paymentsLeft">
<div>Payments</div>
<div>Inquiries</div>
<div>Trade</div>
</div>
</div>
I am having difficulty getting it positioned over the black border. I can change the display to inline-block, increase the height of the A element, but it sits underneath all the time. Tried also to change to position:relative and nudge it down a bit. It seems some sort of z-index might work but not sure if it's possible because all elements are contained within the same parent.
Thanks for any tips.
Remove the overflow:hidden from .c-landing-pg-tabs-container and add padding-bottom: 12px; to .c-landing-pg-tabs a.active-tab. The new rules will look like this:
.c-landing-pg-tabs-container {
position: relative;
height: 41px;
width: 100%;
min-width: 240px;
border-bottom: 2px solid #282828;
margin-bottom: 16px;
}
.c-landing-pg-tabs a.active-tab {
border-bottom: 2px solid #FFF;
color: #FFF;
padding-bottom: 12px;
}
Here's your modified fiddle: http://jsfiddle.net/sc5pB/
EDIT: To clarify, I want all 4 elements in a single row, fit 100%. I know I can change the % but I want them flush with the edge of the div
I'm trying to make my labels and input fields fit in a single row and be % based to resize when required.
Problem is, I can't get them to all fit in one row - I think it has something to do with the padding or margins somewhere but can't figure it out.
I've made a JSfiddle here http://jsfiddle.net/ZxRAu/
And here's the relevant CSS
.generalcontainer {
width:65%;
margin:5%;
height:600px;
float:left;
background-color: #CCCCCC;
border: 0px;
}
.generalcontainer > span {
font-family: Calibri;
font-size: 14px;
padding: 4px;
margin: 0px;
.generalcontainer > span.label {
color: #000000;
font-weight: normal;
display: inline-block;
width:25%;
}
.smallentryfield {
color: #000000;
font-weight: bold;
width: 25%;
padding: 4px;
margin: 0px;
}
select.smallentryfield {
box-sizing: content-box;
}
There can be many reasons why the 25% is not working exactly as you expect. One of the reasons is, you have an element that has its width set in percentile but the padding is in pixels. Another reason could be the input elements disregarding the width applied on them because of their borders, margins and padding. While you can set all of these to 0, you ll still face some challenges when you set the display to inline-block coz that will add some space at the bottom of the element in such a way that it will show invisible margin after the element unless of course you use some combination of vertical-align set to top and font-size or line-height.
A possible solution is to have a container element for each of the form elements and set the width of the container to 25% and set it to display: block along with float: left. Then you can set the inner element's widths to 100% and remove their padding and margins.
For example:
<div class="container">
<label>First name</label>
</div>
<div class="container">
<select>
<option selected="selected" value="Mr">Mr</option>
<option value="Mrs">Mrs</option>
</select>
</div>
<div class="container">
<span>First name</span>
</div>
<div class="container">
<input type="text"></input>
</div>
I m calling it 'container' just as an example. You can change it to whatever. You can set the CSS something for the container something like this:
div.container {
color: #000000;
font-weight: normal;
display: block; /*you need this only if you use a span (as per your example)*/
width:25%;
float: left;
padding: 0px;
margin: 0px;
}
And finally for the CSS for the inner elements, you could do something like:
div.container input[type=text], div.container select {
width: 100%;
padding: 0px;
margin: 0px;
border: 0px;
}
This is just a suggestion as to what direction you can take to solve this issue. Here s a jsfiddle to start playing with this concept in your particular scenario:
http://jsfiddle.net/f8dUC/3/
Hope that helps!
I guess, it just required a <br> tag there, look at the example:
http://jsfiddle.net/afzaal_ahmad_zeeshan/ZxRAu/1/
Or if you want this:
http://jsfiddle.net/afzaal_ahmad_zeeshan/ZxRAu/2/
I just lessen down the width to 20%. And it works :)
There were margins and paddings, which were causing the problem. Due to which 25% for four elements would be 100% and the remaining margins. This way the row was broken and formed 2 rows.
So adding 20% removed the issue. You can have the look in the fiddles.
Started again and used Walmiks guidance for containers within the data. Also set % based padding to get it perfect.
I.E.
form {
width:98%;
line-height:24px;
padding: 1% 1% 0 1%;
}
Check out the JSfiddle below
http://jsfiddle.net/FYdhz/
I am having trouble getting a background-image to overlay the border of another div. We have a sidebar panel with various sidebars, including a navigation menu. To the right is the content panel. We'd like anything selected on the sidebar to appear connected to the content panel:
In the example above, there is a background image on the Personal Info <li> tag. I'd like to extend this image one pixel to the right so that the line next to the selected value isn't visible.
Here is my CSS for the submenu (selected) and the Content area to the right:
.submenu-item li span{
padding: 4px 0 4px 16px;
min-height: 16px;
border-bottom:0px;
}
.submenu-item li{
font-size:12px;
border: none;
padding: 0px 0 0px 16px;
}
.submenu-item span.Active{
background-image: url(../images/submenu-select.png);
background-repeat: no-repeat;
}
#Content {
margin-left:190px;
border-left: 1px solid #b0b0b0;
padding: 20px;
background: #FFFFFF;
min-height:600px;
}
Is there a way to do this other than putting a right border on my sidebar (and excluding it on the list item tag)?
If you have a border on that right, you just can't eliminate that part of the border.
However, you're in luck. Try using margin-right: -1px; in your CSS. This will drag the
element to the right 1 pixel, and hopefully over the border. You may need to also set
position: relative;
z-index: 100;
Also, because it's over to the right 1 pixel, to make it align on the left with the others, you may need to make the active element 1 pixel wider.
Alex's solution should work, but another way to do it would be to remove the border-left CSS atrtribute from #Content and instead use a 1 pixel wide gray GIF or PNG image on the DIV containing the submenu items.
Like this:
#SubMenu { background: url(grayline.gif) #CCCCCC top right; }
That would remove the need to worry about the selected submenu element not being aligned.