border-radius not working - css

I'm working on a basic div and for some peculiar reason, border-radius: 7px isn't applying to it.
.panel {
float: right;
width: 120px;
height: auto;
background: #fff;
border-radius: 7px; // not working
}

To whomever may have this issue. My problem was border-collapse. It was set to:
border-collapse: collapse;
I set it to:
border-collapse: separate;
and it fixed the issue.

For anyone who comes across this issue in the future, I had to add
perspective: 1px;
to the element that I was applying the border radius to. Final working code:
.ele-with-border-radius {
border-radius: 15px;
overflow: hidden;
perspective: 1px;
}

To add a bit on to #ethanmay 's answer: (https://stackoverflow.com/a/44334424/8479303)...
If there are contents within the div that has the curved corners, you have to set overflow: hidden because otherwise the child div's overflow can give the impression that the border-radius isn't working.
<!-- This will look like the border-radius isn't working-->
<div style="border: 1px solid black; border-radius: 10px;">
<div style="background: red;">
text!
</div>
</div>
<!-- but here the contents properly fit within the rounded div -->
<div style="border: 1px solid black; border-radius: 10px; overflow: hidden;">
<div style="background: red;">
text!
</div>
</div>
JSFiddle:
http://jsfiddle.net/o2t68exj/

Im just highlighting part of #Ethan May answer which is
overflow: hidden;
It would most probably do the work for your case.

if you have parent element than your parent element must have overflow: hidden; property
because if your children content is getting oveflowed from parent border than your border will be visible .otherwise your borderradius is working but it is hide by your children content.
.outer {
width: 200px;
height: 120px;
border: 1px solid black;
margin-left: 50px;
overflow: hidden;
border-radius: 30px;
}
.inner1 {
width: 100%;
height: 100%;
background-image: linear-gradient(#FF9933,white, green);
border: 1px solid black;
}
<div class="outer">
<div class="inner1">
</div>
</div>

For some reason your padding: 7px setting is nullifying the border-radius. Change it to padding: 0px 7px

Try add !important to your css. Its working for me.
.panel {
float: right;
width: 120px;
height: auto;
background: #fff;
border-radius: 7px!important;
}

in your div class="social-box" css
use
float:right
instead of
float:left

Your problem is unrelated to how you have set border-radius. Fire up Chrome and hit Ctrl+Shift+j and inspect the element. Uncheck width and the border will have curved corners.

Now I am using the browser kit like this:
{
border-radius: 7px;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
}

For my case, I have a dropdown list in my div container, so I can not use overflow: hidden or my dropdown list will be hidden.
Inspired by this discussion: https://twitter.com/siddharthkp/status/1094821277452234752
I use border-bottom-left-radius and border-bottom-right-radius in the child element to fix this issue.
make sure you add it the correct value for each child separately

you may include bootstrap to your html file and you put it under the style file so if you do that bootstrap file will override the style file briefly like this
// style file
<link rel="stylesheet" href="css/style.css" />
// bootstrap file
<link rel="stylesheet" href="css/bootstrap.min.css" />
the right way is this
// bootstrap file
<link rel="stylesheet" href="css/bootstrap.min.css" />
// style file
<link rel="stylesheet" href="css/style.css" />

I had to add display: block in my case to make it work, the essential part being that the display must not be inlined; so the element had the following:
overflow: hidden;
display: flex;
border-radius: 0.5rem;
(note: it also works with display: block)
See for reference: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow

Related

How to add a shadow to a circular CSS image?

Trying to figure out how I add a shadow to 3 images I have central on my page, looks a little weird without one I believe.
At the moment my HMTL code for this is below:
<div id="imagesMain">
<img src="C:\Users\User\OneDrive\Desktop\Cal\Photos\Gym.jpg" id="gym">
<img src="C:\Users\User\OneDrive\Desktop\Cal\Photos\me.jpg" id="me">
<img src="C:\Users\User\OneDrive\Desktop\Cal\Photos\NFL.jpg" id="nfl">
</div>
and my CSS code for these images is also below:
#imagesMain {
padding: 0;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
text-align: center;
padding-top: 5px;
}
#imagesMain img {
height: auto;
width: 10%;
vertical-align: middle;
border-radius: 50%;
padding: 5%;
padding-bottom: 0;
padding-top: 5px;
}
Thanks, Callum
Try using this filter: drop-shadow(1px 14px 5px rgb(14, 17, 17)); and adjust the shadow according to your needs...
You can do that by using a box-shadow generator for CSS3.
CSS3 box-shadow generator
You need to copy the box-shadow and add it to the image.
For images, I'd use a box-shadow property :
div {
box-shadow: 10px 10px 5px grey;
}
The first two arguments are about the height/width of your shadow box, third argument is about the blurring effect and last one is the color of your shadow.

external stylesheet overriding inline styles when using bootstrap

I am trying to turn a page responsive by adding bootstrap. However, my inline styles do not work. The style="width:100%" does not work but rather width:30% from external style sheet gets used. Somehow, element.style can been in firebug and it does not include my inline width style.
<div class="col-sm-3" style="border:1px solid blue; text-align: center;">
<div id="rightAds" style="width: 100% !important;border:1px solid green; ">
Following can be seen in firebug:
element.style {
border: 1px solid green;
visibility: visible;
opacity: 1;
}
#rightAds {
border: 0px solid green;
width: 30%;
/* width: 100%; */
float: right;
margin-top: 1px;
margin-right: 10px;
margin-right: 0px;
margin-top: 10px;
font-family: Arial, Helvetica, sans-serif;
color: #009933;
min-height: 350px;
}
Not sure what is going on. Somehow bootstrap uses external stylesheet's width property for div#rightAds. What is element.style and how can inline width be included in it? I have been searching google for few hours now but not able to solve this problem.
Thanks a lot!
element.style is inline styles....whatever code you write inline will appear in element style
Try adding
.col-sm-3 #rightAds {
width: 100%;
}
Also try including !important if necessary
Also google "css order of precedence" and you will get answer for which css rule get more importance
Remove width: 30%; float: right; from rightAds css definiton and correct dublicate margin-top values that are effecting it (better provide the real css definiton rather than firebug one) and in the div use: <div id="rightAds col-sm-12 pull-right" style="border:1px solid green;">

How to create a flexible leader line in div after a label field

<div class="titelcontent">
<div class="name">Name</div>
<div class="hzline"></div>
</div>
I want name div and hzline div to auto fit 100% in titelcontent.
The label (for example, Name) will vary in length and I want the red underline to span the remainding space of the titlecontent div.
How do I achieve the following? It is easy to do this using tables but I can't figure out how to do this via span or div.
You can use div like a table by using table-cell.
.titlecontent {
display: table;
}
.name {
display: table-cell;
white-space: nowrap;
}
.hzline {
display: table-cell;
border-bottom: 3px solid red;
width: 100%;
}
See DEMO.
Updated to allow background images to show through
You can make the mark-up a bit tighter by using a pseudo-element as follows:
<div class="wrapper">
<div class="inner">Photoshop</div>
</div>
and use the following CSS styling:
div.wrapper {
color:#82439a;
font-size: 16px;
font-weight: bold;
font-family: tahoma;
line-height: 180%;
background: red url(http://placekitten.com/1000/500) no-repeat left top;
overflow: hidden;
}
div.inner {
position: relative;
display: inner;
color: yellow;
padding-right: 0.50em;
border: 1px dotted yellow;
}
div.inner:after {
content: "\A0";
position: absolute;
bottom: 0;
left: 100%;
border-bottom: 5px solid #d71d00;
width: 1000%;
}
Demo fiddle: http://jsfiddle.net/audetwebdesign/wE8bC/
How It Works
The parent element div.wrapper may contain a background image or be transparent and show the background of some ancestor element. You need to set overflow: hidden.
For the label (<div.inner>), set position: relative and then generate a 100% width pseudo-element with a bottom border to serve as an underline. Use absolute positioning to place div.inner:after to the right of <div.inner> (left: 100%) and make the width relatively large. The pseudo-element will trigger an overflow condition but this is taken care of by hiding the overflow in the parent element. You can control left/right spacing using padding.
You can use set the display property to either inline or inline-block. If you use display: inline, it will work in IE7; adjust the line height as needed for styling.
Note that the generated content is a non-breaking space, hex code "\A0".
Support for IE7
If you need to support IE7, you will need a hack if you use inline-block as discussed in a previous question: IE7 does not understand display: inline-block
IE7 also does not support table-cell so some of the other posted solutions will face the same limitation.
Or an alternative to using display: table:
.name {
float: left;
}
.line-wrapper {
display: block;
overflow: hidden;
padding-top: 6px;
}
.hzline {
border-bottom: 3px solid red;
width: 100%;
}
See example.
I've guessed you are looking something like this. Please find my solution based on my understanding about the image you posted.
HTML
<div>
<span>Photoshop</span>
</div>
<div>
<span>Adobe Illustrator</span>
</div>
<div>
<span>3D Max</span>
</div>
<div>
<span>Maya</span>
</div>
<div>
<span>Windows 8 Pro</span>
</div>
CSS
div {
line-height: 150%;
border-bottom: 5px solid #d71d00;
}
div span{
position:relative;
bottom: -10px;
background:#fff;
padding: 0 5px;
color:#82439a;
font-size: 16px;
font-weight: bold;
font-family: tahoma;
}
Please do let me know your feedback. Thanks

strange CSS issue on IE8

I have a div which contains another div with a background image:
<div class="icePnlGrp graMyTasksHomePanelDiv">
<div class="icePnlGrp graMyTasksHomePanelTitleDiv" id="j_id157:j_id165">
<label class="iceOutLbl graMyTasksHomePanelTitle" id="j_id157:j_id166">PLAN</label>
<!--rest of the code--!>
</div>
</div>
This looks fine on Chrome and Firefox:
But on IE it looks strange:
The CSS classes for those two divs:
.gramytaskshomepaneldiv {
background-color: whiteSmoke;
width: 156px;
height: 150px;
margin-right: 50px;
border-right: 3px #EEE9E9 ridge;
border-bottom: 3px #EEE9E9 ridge;
display: inline;
float: left;
margin-bottom: 15px;
}
.gramytaskshomepaneltitlediv {
background: url('/resources/images/external/navigation_arrow.png');
height: 40px;
margin-top: -30px;
width: 185px;
position: relative;
margin-left: -4px;
}
Can you please give a helping hand? Most of the IE 8 issues I had I've solved using position relative, but here this simply does not work...
Thanks...
Ps: If I do hover on a link on IE, on the same page, on that main div (because the rest of the code contains those links), the image AUTOMATICALLY RENDERS fine... Or if I disable any css property from IE developer tools the page is re-render and the image appears fine...which is really strange, ineded...

Padding within inputs breaks width 100%

Ok, so we know that setting padding to an object causes its width to change even if it is set explicitly. While one can argue the logic behind this, it causes some problems with some elements.
For most cases, you just add a child element and add padding to that one instead of the one set to 100%, but for form inputs, that's not a possible step.
Take a look at this:
body {
font-size: 14px;
margin: 0px;
padding: 0px;
}
DIV.formfield {
clear: both;
margin: 0px;
padding: 10px;
}
DIV.formlabel {
margin-top: 20px;
padding: 5px;
font-weight: bold;
text-align: left;
}
DIV.formvalue {
background-color: #eee;
border: 1px solid red;
padding: 10px;
margin: 0px;
}
DIV.formvalue.correct {
border: 1px solid green;
}
textarea.textarea {
width: 100%;
min-height: 80px;
}
input.input {
width: 100%;
padding: 5px;
}
input.input2 {
width: 100%;
}
input.input3 {
width: 100%;
padding: 5px;
margin: -5px;
}
input.input4 {
width: 100%;
padding: 10px;
margin: -10px;
}
input.input5 {
width: 100%;
padding: 10px;
box-sizing: border-box;
}
<div class='formfield' id='field_text'>
<div class='formlabel'>No padding</div>
<div class='formvalue'>
<textarea class='textarea' cols='80' rows='10' name='text'>No padding here</textarea>
</div>
<div class='formlabel'>Also no padding</div>
<div class='formvalue'>
<input type='text' class='input2' name='apa' value='Or here...' />
</div>
<div class='formlabel'>5px padding, which extends the parent element, d'oh!</div>
<div class='formvalue'>
<input type='text' class='input' name='apa' value='I dont want to extend outside the square!' />
</div>
<div class='formlabel'>5px padding and -5px margin, this does the trick, almost...</div>
<div class='formvalue'>
<input type='text' class='input3' name='apa' value='I dont want to extend outside the square!' />
</div>
<div class='formlabel'>10px padding and -10px margin, things are falling apart on the right side</div>
<div class='formvalue'>
<input type='text' class='input4' name='apa' value='I dont want to extend outside the square!' />
</div>
<div class='formlabel'><img src="/bilder/icons/badges/ok.png" width="16" height="16" border="0"> 10px padding and box-sizing: border-box</div>
<div class='formvalue correct'>
<input type='text' class='input5' name='apa' value='I dont want to extend outside the square!' />
</div>
</div>
The second input has its padding set to 5px which I very much prefer to the default setting. But unfortunately that makes the input grow 10px in all directions, including adding 10px to the 100% width.
Problem here is that I can't add a child element inside the input so I can't fix it. So the question is:
Is there any way to add padding inside the input while still keeping the width 100%? It need to be 100% since the forms will render in different width parents so I don't know beforehand the width of the parent.
Using CSS3 you can use the property box-sizing to alter how the browser calculate the width of the input.
input.input {
width: 100%;
box-sizing: border-box;
}
You can read more about it here: http://css-tricks.com/box-sizing/
I don't know how cross browser compatible it is (it works in firefox and safari), but you could try this solution:
DIV.formvalue {
padding: 15px;
}
input.input {
margin: -5px;
}
(Only posted the values that I changed)
One option is to wrap the INPUT in a DIV which has the padding.
CSS:
div.formvalue {
background-color: #eee;
border: 1px solid red;
padding: 10px;
margin: 0px;
}
div.paddedInput {
padding: 5px;
border: 1px solid black;
background-color: white;
}
div.paddedInput input {
border: 0px;
width: 100%;
}
HTML:
<div class="formvalue">
<div class="paddedInput"><input type="text" value="Padded!" /></div>
</div>
The oft-forgotten calc can come to the rescue here:
input {
width: calc(100% - 1em);
padding: 0.5em;
}
Since we know the padding will add to the width of the element, we simply subtract the padding from the overall width. It's supported by all major browsers, is responsive, and doesn't require messy wrapper divs.
I've been having some issues with something similar to this. I have tds with inputs of 100% and a small padding. What I did was compensate for the padding on the td as follows:
.form td {
padding-right:8px;
}
.form input, .form textarea {
border: 1px solid black;
padding:3px;
width:100%;
}
padding of 8px to include the border and padding of the input/textarea.
Hope this helps!
Perhaps take the border+background off the input, and instead enclose it in a div with border+background and width:100%, and set a margin on the input?
One solution I have found works is to absolutely position the input with a relatively positioned parent tag.
<p class="full-width-input">
<input type="text" class="text />
</p>
The apply the style:
p.full-width-input {
position: relative;
height: 35px;
}
p.full-width-input input.text {
position: absolute;
top: 0;
left: 0;
right: 0;
padding: 5px;
}
The only thing to be aware of is that the paragraph tag needs a height setting as its absolutely positioned children will not expand its height. This avoids the need to set width: 100% by locking it to the left and right sides of the parent element.
Try using percentages for your padding:
.input {
// remove border completely
border: none;
// don't forget to use the browser prefixes
box-shadow: 0 0 0 1px silver;
// Use PERCENTAGES for at least the horizontal padding
padding: 5%;
// 100% - (2 * 5%)
width: 90%;
}
If you're worried about users on old browsers who can't see the box-shadow, just give the input a subtle background colour as backup. If you're using pixels for this sort of thing, then the chances are you're using them elsewhere, which could present a few extra-challenges, let me know if you encounter them.
Only thing I know to prevent this is assign values like that 100%-10. But it has some compatibility issues tho.

Resources