border-radius + overflow:hidden = thin black line - html

here is my issue:
<div class="wrap">
<div class="inner"></div>
</div>
.wrap {
position: relative;
width: 200px;
height: 66px;
background: black;
overflow: hidden;
border-radius: 100px;
}
.inner {
position: absolute;
top: 0;
left: 50%;
right: 0;
bottom: 0;
background: white;
}
http://jsfiddle.net/cjW7Q/1/
Notice thin black line on the right side.
Any ideas how to get rid of it?
UPDATE
There is a lot of workarounds, but problem is that overflow:hidden doesn't work correctly. Imagine that instead of .inner I have an image, that I want to move around with transition using transform (for hardware acceleration). I'll try to update demo later.

<edit>multiple bg mixing image and gradient can be used with animation too without extra markup DEMO </edit>
This is a commun defaut , you see it in FF too.
I would say , paint it the other way round :
.wrap doesn't even need a bckground color.
http://jsfiddle.net/cjW7Q/2/
.wrap {
position: relative;
width: 200px;
height: 66px;
overflow: hidden;
border-radius: 100px;
}
.inner {
position: absolute;
top: 0;
width: 50%;
left:0;
bottom: 0;
background: black;
}
Else you can use a gradient and no inner element:
.wrap {
position: relative;
width: 200px;
height: 66px;
overflow: hidden;
border-radius: 100px;
background:linear-gradient(to left,white 50%,black 50%);
}
DEMO

Here's a Work Around
.inner {
position: absolute;
top: 0;
left: 0;
right: 50%;
bottom: 0;
background: black;
}
Apply the same background of it's parent for the parent element (here there's no need of background at all)

Add "border-right-width: 0px;" to .wrap.

Try this CSS,
.wrap {
position: relative;
width: 200px;
height: 66px;
background: black;
overflow: hidden;
border-top-left-radius: 100px;
border-bottom-left-radius: 100px;
}
.inner {
position: absolute;
top: 0;
right: 0;
left: 50%;
bottom: 0;
background: white;
}
DEMO

border:0px
paddind : 10 px
background:#FFF

Related

Preventing shapes from overflow + positioning?

I'm trying to create a component where there is a hollow circle that is cropped at the bottom-left corner:
I've attempted to do so with the pseudo classes below but am facing two issues after working with it for a while (dimensions of the circle are not the same, but I will address this later):
The circles overflow outside of the component
The positioning of the circles changes depending on where the element is used.
#element {
max-width: 750px;
height: 350px;
border-radius: 8px;
background-color: #008001;
}
#element:before {
content: '';
position: absolute;
width: 100px;
height: 100px;
z-index: 1;
background: #008001;
border-radius: 50%;
top: 290px;
right: 94%;
}
#element:after {
content: '';
position: absolute;
width: 150px;
height: 150px;
background: #fff;
opacity: 0.5;
border-radius: 50%;
top: 260px;
right: 92%;
}
<div id="element"></div>
Set overflow:hidden to #element. SO `we can hide overflowing content of ::before CSS. Also set #element to position:relative, which set's boundary for ::before when we try to set it after making it absolute.
Once above =e things are done, just apply #element::before to bottom:-50px and left:-50px, I have used 50px as height and width were set to 100px.
Then to get the border just set border:25px solid #yourolor.
#element {
max-width: 750px;
height: 350px;
border-radius: 8px;
background-color: #008001;
overflow: hidden;
position: relative;
}
#element:before {
content: '';
position: absolute;
width: 100px;
height: 100px;
z-index: 4;
background: #008001;
bottom: -50px;
left: -50px;
border-radius: 100%;
border: 25px solid #c5ffc6;
}
<div id="element"></div>

Columns as backgrounds will not expand to match page height

I am using two divs to create the look of a two-tone background. behind my container div, the left side is blue and the right side is yellow. My css for these column divs is:
#bluecol{
height:100%;
background-color: #5C8AE6;
display: inline;
float: none;
left: 0px;
overflow-x: hidden;
overflow-y: hidden;
position: absolute;
top: 0px;
width: 50%;
z-index: -5;}
and for the yellowcol is the same, except positioned to the right, naturally. Currently both divs works fine but I cannot get them to match the height of the content within my container, I can only set the height manually or to 100%, which only takes up the browser's window. My container is set to height:max-content so is unhelpful in this situation.
I want the two column divs to match whatever the containers height is. Any suggestions would be great!
Js fiddle: https://jsfiddle.net/ak0kp9xd/
Try like this: Demo
html, body {
height: 100%;
overflow: hidden;
position: relative;
}
#bluecol {
height:100%;
background-color: #5C8AE6;
display: inline;
float: none;
left: 0px;
overflow-x: hidden;
overflow-y: hidden;
position: absolute;
top: 0px;
width: 50%;
z-index: -5;
}
#yellowcol {
height:100%;
background-color: rgb(255, 204, 0);
display: inline;
float: none;
right:0px;
overflow-x: hidden;
overflow-y: hidden;
position: absolute;
top: 0px;
width: 50%;
z-index: -5;
}
#container {
background-color:#E5ECFB;
font-family:'calibri';
margin:10px;
overflow:hidden;
z-index:5;
font-size:medium;
height: 100%;
}
Your background blocks must be inside #container to take it's height.
Also you can use :before to reduce HTML markup:
#container {
position: relative;
background-color: rgb(255, 204, 0);
padding: 10px;
}
#container:before {
content: '';
position: absolute;
left: 0;
top: 0;
width: 50%;
height: 100%;
background-color: #5C8AE6;
display: block;
z-index: 1;
}
#container .content {
position: relative;
z-index: 10;
background-color: #E5ECFB;
border-right: 11px solid #FFE994;
border-left: 11px solid #AFC6F3;
}
<div id="container">
<div class="content">Whatever</div>
</div>

CSS: margin auto and position absolute

I'm trying to create a "button" with 2 sections (each is 50% of the height of the div) separated by an horizontal bar. Each of the sections has centered text. The size of the button is going to be manipulated using javascript, and I'm trying to avoid also using javascript to position the elements inside the "button".
What I have so far is http://jsfiddle.net/u5u7d31p/2/, but i'm having a problem centering the horizontal bar. If I change the position of the separator to relative, the bar is centered, but then it changes the position of the bottom part of the text. I can also change the margin to a static value (margin: 0 63px;) to center it, but I would like to avoid it if there is an easier solution that doesn't require javascript.
.img_overlay .separator{
position: absolute;
top: -1px;
left: 0;
height: 3px;
width: 70px;
margin: 0 auto;
background: #444;
}
Any ideas? Thanks.
All codes are ok. Just put this css below to .img_overlay .separator class.
Full code is below:
.img_overlay .separator {
position: absolute;
top: -1px;
left: 0;
height: 3px;
width: 70px;
margin: 0 auto;
background: #444;
right: 0;
}
view my demo on jsfiddle
.img{
float: left;
background-repeat:no-repeat;
background-size:100% 100%;
border-radius: 4px;
width: 200px;
height: 51px;
background: red;
overflow: hidden;
}
.img_overlay{
width: 100%;
height: 100%;
background: #222;
color: #ddd;
position: relative;
opacity: 0.8;
}
.img_overlay>div{
display: block;
width: 100%;
height: 50%;
text-align: center;
position: relative;
}
.img_overlay .middle{
position: relative;
top: 50%;
transform: translateY(-50%);
}
.img_overlay .separator{
height: 3px;
width: 70px;
margin: 0 auto;
background: #444;
}
<div class="img">
<div class="img_overlay">
<div class="img_show_details">
<div class="middle">details</div>
</div>
<div class="img_open">
<div class="separator"></div>
<div class="middle">open</div>
</div>
</div>
</div>
All I did was taking off :
.img_overlay .separator{
position: absolute;
top: -1px;
left: 0;
}
This following fix works okay in firefox and chrome but mess in IE.
I fixed height in div, top in middle and top in separator
.img_overlay>div {
display: block;
width: 100%;
height: 40%;
text-align: center;
position: relative;
}
.img_overlay .middle {
position: relative;
top: 60%;
transform: translateY(-50%);
}
.img_overlay .separator {
position: relative;
top: 5px;
left: 0;
height: 3px;
width: 70px;
margin: 0 auto;
background: #444;
}
here's the demo in jsfiddle.

How to add a half circle at the bottom middle of my header?

Here is how I want it to look:
I realize this is an ugly mockup and obviously when I do it for real the proportions will look better, but I am wondering how you would go about doing this with CSS.
fiddle is here http://jsfiddle.net/bU3QS/1/
<div class="header">
</div>
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #000;
z-index: 10000;
height: 110px;
overflow: hidden;
}
Use the :after pseudo element:
.header:after {
content: '';
position: absolute;
background: black;
width: 50px;
height: 50px;
z-index: 1;
border-radius: 50%; /* Makes the element circular */
bottom: -25px;
left: 50%;
margin-left: -25px;
}
For this solution, overflow: hidden; has been removed from the .header CSS.
Here's a fiddle: http://jsfiddle.net/t97AX/
Here's another approach, that doesn't rely on the width of the semicircle to center it properly:
.header:after {
content: '';
position: relative;
top: 100%;
display: block;
margin: 0 auto;
background: red;
width: 50px;
height: 25px;
border-radius: 0 0 50px 50px;
}
The fiddle (semicircle red for the sake of clarity): http://jsfiddle.net/x4mdC/
More on :before and :after: http://www.w3.org/TR/CSS2/selector.html#before-and-after
Use :after and border-radius to create the semicircle.
.header {
position: fixed;
top: 0;
left: 0;
right: 0;
background-color: #000;
height: 110px;
}
.header:after {
content: '';
background-color: red;
position: absolute;
display: block;
width: 100px;
top: 110px;
left: 50%;
margin-left: -50px;
height: 50px;
border-radius: 0 0 50px 50px;
}
Demo: http://jsfiddle.net/bU3QS/2/
<div class="header">
<div class="circle">
</div>
</div>
.header {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #000;
height: 110px;
}
.circle {
height: 100px;
width: 100px;
border-radius: 100px;
background-color: black;
margin: auto;
position: relative;
top:45px;
}
in action: http://jsfiddle.net/NickWilde/ngcce/

How to set up the browser scrollbar to scroll part of a page? (higher than footer part hidden) just like http://i-donline.com/

How to set up the browser scrollbar to scroll part of a page? (higher than footer part hidden) just like http://i-donline.com/
http://jsfiddle.net/hVvfn/2/
.header{
position: fixed;
left: 0;
top: 0;
width: 1000px;
height: 100px;
background: blue;
z-index: 1;
}
.contentwrap{
position: absolute;
left: 0;
top: 100px;
width: 1000px;
height: 250px;
background: ;
}
.footer{
position: fixed;
left: 0;
top: 350px;
width: 1000px;
height: 300px;
background: blue;
}
.row{
position: relative;
left: 0;
top: 0;
width: 800px;
height: 250px;
border: purple 1px solid;
background: gray;
}​
There is a library called as iScroll. Used just for these kind of things. You can check it out I think it will help. In fact I have used it many times. Works like charm. Here is the link:
iScroll here