My UI has an unordered list on the left. When a list item is selected, a div appears on the right of it. I'd like to have a curved outer corner where the <li> and the <div> meet. Some people call this a negative border radius or an inverted corner. See the white arrow in the image below.
To extend the blue <li> to the edge of the <ul>, I'm planning to do something like this:
li {
right-margin: 2em;
border-radius: 8px;
}
li.active {
right-margin: 0;
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
Is there a better way to extend the <li> to the edge of the <ul>? Obviously, I'll include the webkit and mozilla border radius CSS as well.
The main thing I'm unsure about is that outer corner underneath the bottom right corner of the active <li>. I have some ideas, but they seem like hacks. Any suggestions?
NOTE that the <ul> is indicated in grey, but it would be white in the real design. Also, I'm planning to use Javascript to position the <div> correctly when an <li> is selected.
Well, as it turns out, I managed to solve the problem myself. I hacked together a demo -- check it out.
Essentially, several additional DOM elements are required and a fair amount of CSS. And as mentioned in the link provided by #Steve, a solid background is required. I don't believe there is any way to do this over a gradient background or other pattern.
I ended up with HTML like this:
ul.selectable {
padding-top: 1em;
padding-bottom: 1em;
width: 50%;
float: left;
}
ul.selectable li {
margin: 0 3em 0 4em;
border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
}
ul.selectable li.active {
margin-right: 0;
}
ul.selectable li.active dl {
background-color: #4f9ddf;
}
ul.selectable li dt {
background-color: #dfd24f;
padding: 1em;
margin-left: -2em;
margin-right: -2em;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
ul.selectable li dd {
padding: 0.25em;
background-color: #fff;
}
ul.selectable li.active dt {
background-color: #4f9ddf;
margin-right: 0;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-right-radius: 0;
-khtml-border-top-right-radius: 0;
-khtml-border-bottom-right-radius: 0;
-moz-border-radius-topright: 0;
-moz-border-radius-bottomright: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
ul.selectable li.active dd.top {
-webkit-border-bottom-right-radius: 8px;
-khtml-border-bottom-right-radius: 8px;
-moz-border-radius-bottomright: 8px;
border-bottom-right-radius: 8px;
}
ul.selectable li.active dd.bot {
-webkit-border-top-right-radius: 8px;
-khtml-border-top-right-radius: 8px;
-moz-border-radius-topright: 8px;
border-top-right-radius: 8px;
}
div.right {
float: left;
padding-top: 3em;
width: 50%;
}
div.content {
height: 15em;
width: 80%;
background-color: #4f9ddf;
padding: 1em;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
<ul class="selectable">
<li>
<dl>
<dd class="top"></dd>
<dt>Title</dt>
<dd class="bot"></dd>
</dl>
</li>
<li class="active">
<dl>
<dd class="top"></dd>
<dt>Title</dt>
<dd class="bot"></dd>
</dl>
</li>
<li>
<dl>
<dd class="top"></dd>
<dt>Title</dt>
<dd class="bot"></dd>
</dl>
</li>
</ul>
<div class="right">
<div class="content">This is content</div>
</div>
I haven't optimized any of the CSS as I just hacked it together. But perhaps it will help someone else. I've only tested this in Google Chrome on Mac OSX.
Cleaner Solution (Less Code & Background Gradient Allowed)
See the fiddle (or another), which is using this html:
<ul class="selectable">
<li>Title</li>
<li class="active">Title</li>
<li>Title</li>
<li>Title</li>
</ul>
<div class="right">
<div class="content">This is content</div>
</div>
And this css (the key is to allow the border-radius and border-width on the pseudo-elements to make the inverted circle for you; I've omitted the gradient code.):
ul.selectable {
padding-top: 1em;
padding-bottom: 1em;
width: 50%;
float: left;
}
ul.selectable li {
margin: 1em 1em 1em 2em;
padding: 1em;
border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
background-color: #dfd24f;
position: relative;
}
ul.selectable li.active {
margin-right: 0;
background-color: #4f9ddf;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-right-radius: 0;
-khtml-border-top-right-radius: 0;
-khtml-border-bottom-right-radius: 0;
-moz-border-radius-topright: 0;
-moz-border-radius-bottomright: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
ul.selectable li.active:before,
ul.selectable li.active:after {
content: '';
position: absolute;
left: 100%; /* I use this instead of right: 0 to avoid 1px rounding errors */
margin-left: -8px; /* I use this because I am using left: 100% */
width: 8px;
height: 8px;
border-right: 8px solid #4f9ddf;
z-index: -1;
}
ul.selectable li.active:before {
top: -8px;
border-bottom: 8px solid #4f9ddf;
-webkit-border-bottom-right-radius: 16px;
-khtml-border-bottom-right-radius: 16px;
-moz-border-radius-bottomright: 16px;
border-bottom-right-radius: 16px;
}
ul.selectable li.active:after {
bottom: -8px;
border-top: 8px solid #4f9ddf;
-webkit-border-top-right-radius: 16px;
-khtml-border-top-right-radius: 16px;
-moz-border-radius-topright: 16px;
border-top-right-radius: 16px;
}
div.right {
float: left;
padding-top: 3em;
width: 50%;
}
div.content {
height: 15em;
width: 80%;
background-color: #4f9ddf;
padding: 1em;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
I came up with a solution that requires less markup. In summary, instead of using margins it uses white rounded borders, then we position the active li behind the white rounded borders to achieve the inverted border-radius effect.
http://jsfiddle.net/zrMW8/
<ul class="selectable">
<li>
Title
</li>
<li class="active">
Title
</li>
<li>
Title
</li>
<li>
Title
</li>
</ul>
<div class="right">
<div class="content">This is content</div>
</div>
And less CSS too! (this is mind bending):
a { color: #000; text-decoration: none;}
ul.selectable {
padding: 1em 1em;
width: 40%;
float: left;
}
ul.selectable li {
margin: -1em 0 0 0;
border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border: solid #fff 1em;
position: relative;
}
ul.selectable li a {
background-color: #dfd24f;
padding: 1em;
display: block;
border-radius: 8px;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
}
ul.selectable li.active {
margin: -1em -1em -1em 1em;
border: solid #4f9ddf 1em;
border-left: solid #fff 1em;
background-color: #4f9ddf;
position: static;
}
ul.selectable li.active a {
margin: 0 0 0 -1em;
border-left: solid #4f9ddf 1em;
background-color: #4f9ddf;
position: static;
text-indent: -1em;
}
div.right {
float: left;
padding-top: 3em;
width: 50%;
margin-left: -1em;
}
div.content {
height: 15em;
width: 80%;
background-color: #4f9ddf;
padding: 1em;
-webkit-border-radius: 8px;
-khtml-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
To tell you the truth I'm not sure it's a better version, it does make gradient/image backgrounds easy (for non active li's, at least) but you can't apply an image/gradient background to the body. It's also "bad magic" en the sense that it works in a non-intuitive way.
To do this over a non-solid bg, I don't think you can do it with CSS, but you could use canvas or SVG to the same effect - not exactly what you asked for, though.
However, there does appear to be a proposal for negative border radius that would solve the problem. Maybe some day, right.
This nice Inverse Border Radius in CSS tutorial could do the trick. Explains how to do inverse border radius for tabs. But it could be easily adapted to streamline your css since it uses :after instead of creating too many extra elements.
Related
I have problem, I can't align two buttons in one line.
I tried to set padding of span class pptext2 but without success.
Here is code
http://jsfiddle.net/71782p4L/1/
HTML
<div class="ppdiv">
<button class="ppenvelope"><img src="http://i.imgur.com/RfLMyak.jpg" alt="Slika"></button><button class="pptext"><span class="pptext2">PRIVATE MESSAGE</span></button>
</div><!--Zatvoren ppdiv-->
CSS
.ppdiv{
padding-top:22px;
padding-left: 19px;
}
.ppdiv img{
padding:10px;
font-size: 20px;
}
.ppenvelope{
border:none;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
background: #b2d4dd;
}
.pptext{
border:none;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
background: #c9e0e6;
}
.pptext2{
display: inline-block;
color:#4c6974;
padding-top: 15px;
padding-bottom:13px;
padding-left: 13px;
}
I would set float: left; on both buttons and overflow: hidden; on .ppdiv. To make sure both buttons stay the same height, also set height on them (e.g. height: 48px;). You can also remove the span.pptext2 element altogether, unless you need it for other purposes. Take a look at the fiddle: https://jsfiddle.net/igi33/ck4w6cLq/1/.
HTML:
<div class="ppdiv">
<button class="ppenvelope">
<img src="http://i.imgur.com/RfLMyak.jpg" alt="Slika">
</button>
<button class="pptext">PRIVATE MESSAGE</button>
</div>
CSS:
.ppdiv{
overflow: hidden;
}
.ppenvelope, .pptext {
float: left;
border: none;
height: 48px;
}
.ppenvelope{
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
background: #b2d4dd;
}
.ppdiv img{
padding:10px;
}
.pptext{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
background: #c9e0e6;
color:#4c6974;
}
Use vertical-align: middle; on both buttons.
.pptext {
background: none repeat scroll 0 0 #c9e0e6;
border: medium none;
border-bottom-right-radius: 4px;
border-top-right-radius: 4px;
vertical-align: middle;
}
.ppenvelope {
background: none repeat scroll 0 0 #b2d4dd;
border: medium none;
border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
vertical-align: middle;
}
https://jsfiddle.net/71782p4L/2/
Here you are.
.ppdiv {
height:43px;
overflow:hidden;
}
.ppdiv img {
padding:10px;
}
.ppenvelope {
border:none;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
background: #b2d4dd;
float:left;
height:100%; /*Sets height to 100% of current container, of which is ppdiv (43px) */
}
.pptext {
border:none;
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
background: #c9e0e6;
height:100%; /*Sets height to 100% of current container, of which is ppdiv (43px)*/
}
I have a galery and I´m trying to crop the photos that have height more than 150px to have all images with the same height. Actually I have this --> http://postimg.org/image/9t605lhdv/
I would like to make something similar to this --> http://postimg.org/image/v1zjjwuyp/
For example this website have this "crop", but I can not get it seeing his css. --> http:// postimg.org/image/vq8e2utoh/
My html is:
<ul class="preview-grid container" id="preview-grid">
<li>
<a href="photo.jpg" data-largesrc="photo.jpg" data-title="photo-title" data-description="photo">
<img src="photo.jpg" alt="photo.jpg" class="img">
</a>
</li>
<li>
<a href="photo2.jpg" data-largesrc="photo2.jpg" data-title="photo-title" data-description="photo2">
<img src="photo2.jpg" alt="photo2.jpg" class="img">
</a>
</li>
<li>
<a href="photo3.jpg" data-largesrc="photo3.jpg" data-title="photo-title" data-description="photo">
<img src="photo3.jpg" alt="photo3.jpg" class="img">
</a>
<li>
<a href="photo4.jpg" data-largesrc="photo4.jpg" data-title="photo-title" data-description="photo4">
<img src="photo4.jpg" alt="photo4.jpg" class="img">
</a>
</li>
</ul>
and my css is:
.preview-grid {
list-style: none;
padding: 20px 0;
margin: 0 auto;
text-align: center;
width: 100%;
color: #d6d6d6;
}
.preview-grid li {
display: inline-block;
margin: 12px 10px;
vertical-align: top;
height: auto;
width: 22%;
}
.preview-grid li>a, .preview-grid li>a img {
border: none;
outline: none;
display: block;
position: relative;
width: 100%;
height: auto;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 0;
-webkit-border-top-left-radius: 15px;
-moz-border-radius-topright: 0;
-moz-border-radius-bottomright: 15px;
-moz-border-radius-bottomleft: 0;
-moz-border-radius-topleft: 15px;
border-top-right-radius: 0;
border-bottom-right-radius: 15px;
border-bottom-left-radius: 0;
border-top-left-radius: 15px;
-moz-background-clip: padding-box;
-webkit-background-clip: padding-box;
background-clip: padding-box;
/* max-height: 136px; */
-webkit-box-shadow: 0 0 13px 0 #E8E8E8;
box-shadow: 0 0 13px 0 #E8E8E8;
}
I hope someone can help me!!
Thank you!!
Solved Here: Image As YOu Want
In Example The last6 image is cropped. as you asked in question!
Another hover effect if want to use Hover over effect
CSS Modified
.preview-grid {
list-style: none;
padding: 20px 0;
margin: 0 auto;
text-align: center;
width: 100%;
color: #d6d6d6;
}
.preview-grid li {
display: inline-block;
margin: 12px 10px;
vertical-align: top;
height: 150px;
width: 22%;
}
.preview-grid li>a, .preview-grid li>a img {
border: none;
outline: none;
display: block;
position: relative;
width: 150px;
height: 150px;
overflow:hidden;
border:1px solid yellow;
-webkit-border-top-right-radius: 0;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 0;
-webkit-border-top-left-radius: 15px;
-moz-border-radius-topright: 0;
-moz-border-radius-bottomright: 15px;
-moz-border-radius-bottomleft: 0;
-moz-border-radius-topleft: 15px;
border-top-right-radius: 0;
border-bottom-right-radius: 15px;
border-bottom-left-radius: 0;
border-top-left-radius: 15px;
-moz-background-clip: padding-box;
-webkit-background-clip: padding-box;
background-clip: padding-box;
/* max-height: 136px; */
-webkit-box-shadow: 0 0 13px 0 #E8E8E8;
box-shadow: 0 0 13px 0 #E8E8E8;
}
.preview-grid li>a img {
width:100%;
height:auto;
}
What I've done here is just make a box like the image below but how to fade a color and set
margin-left= 10px; margin-top: 5px for the title's box with CSS
Demo
HTML:
<div id="_div">
<span class="_top">Company Performance</span>
<span class="_content">Electric Consumption: 2300kW</span>
<div>
CSS:
#_div {
display: block;
-webkit-border-radius: 7px;
-moz-border-radius: 7px;
border-radius: 7px;
width: 300px;
height: 100px;
background-color: #FFFFFF;
box-shadow: 5px 5px 5px #e0e6e8;
border: 1px solid #c1dee0;
}
._top {
display: block;
background-color: #D0E3EC;
-webkit-border-top-left-radius: 7px;
-webkit-border-top-right-radius: 7px;
-moz-border-radius-topleft: 7px;
-moz-border-radius-topright: 7px;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
padding-bottom: 10px;
border-bottom: 1px solid #c1dee0;
}
._content {
display: block;
margin-left: 10px;
margin-top: 10px;
}
Not clear why you want to use the margin
if you want to align the text use padding with _top class
Remove all the padding from _top class and add
padding: 5px 0 5px 10px;
To fade the color use opacity: .5
To solve my problems, I have used linear-gradient(#D0E3EC, #e9f2f6); and padding-left: 10px; padding-top: 5px;. To be more detail, please have a look on the code below.
Code:
._top {
display: block;
-webkit-border-top-left-radius: 7px;
-webkit-border-top-right-radius: 7px;
-moz-border-radius-topleft: 7px;
-moz-border-radius-topright: 7px;
border-top-left-radius: 7px;
border-top-right-radius: 7px;
padding-bottom: 10px;
border-bottom: 1px solid #c1dee0;
background-image:
linear-gradient(#D0E3EC, #e9f2f6);
padding-left: 10px;
padding-top: 5px;
}
Demo
This fluid design works fine on all browsers on my laptop, but on my android and iphone the link button is split between two lines. If I change the width percentage of style (a span) I can get it to work, but then it's width is no longer as wide as the container below it and it's needs to be.
I was assuming that style (a span) could only fill in the area between style (a em) and style (a b), I guess I was wrong.
Thanks in advance for anyone that can help me on this.
Styles
.main_container {
overflow: hidden;
width: 100%;
height: 100%;
background-image: url(../images/bgdots.png);
background-repeat: repeat-x y;
background-attachment: fixed;
background-color: transparent;
padding-bottom: 20px;
}
h2.acc_trigger {
display: block;
margin: 0 0 2px 0;
width: 95%;
height: 30px;
font-size: 1.5em;
font-weight: normal;
text-align: center;
margin-left: auto;
margin-right: auto;
}
a em{
display: block;
float: left;
background: url(../images/navs.png) no-repeat 0 0;
width: 26px;
height: 30px;
}
a span{
display: block;
float: left;
background: url(../images/navs_c.png) repeat-x;
width: 95%;
height: 30px;
}
a b{
display: block;
float: left;
background: url(../images/navs.png) no-repeat -28px 0;
width: 5px;
height: 30px;
}
.acc_container {
margin: 0 0 2px;
overflow: hidden;
font-size: 1.2em;
width: 95%;
clear: both;
background: #fff;
border: 2px solid #3cf;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
-moz-border-radius-topright: 5px;
-moz-border-radius-topleft: 5px;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
margin-left: auto;
margin-right: auto;
}
Example HTML
<h2 class="acc_trigger">
<a href="#"><em> </em> <span>
home</span> <b> </b></a>
</h2>
<div class="acc_container">
<h3>
Content content content!
</h3>
<p>
Content and more content, content with style and interest
that makes you want to read on.
</p>
</div>
add in style float:left might resolve your issue
You want your to have a percentage as well. I assume you want the code to work like my example here
a em{
display: block;
float: left;
background: url(../images/navs.png) no-repeat 0 0;
width: 2%;
height: 30px;
}
a b{
display: block;
float: left;
background: url(../images/navs.png) no-repeat -28px 0;
width: 2%;
height: 30px;
}
Basically 95% plus 26px plus 26px can equal > the screen. So it wraps. You want all three of those elements to have a percentage to keep it jiving.
You don't need inline styles if you are using CSS
<h2 class="acc_trigger">
<em> </em> <span> home</span> <b> </b>
</h2>
should be
<h2 class="acc_trigger">home</h2>
a.acc_trigger{
font-style:italic;
font-weight: bold;
}
H2 is a block-level element. If you want to make it inline just do this:
<h2 class="acc_trigger">home</h2>
a.acc_trigger{
font-style:italic;
font-weight: bold;
display: inline;
}
html:
<div class="no-contact-info">
<textarea></textarea>
<span>no contact info</span>
</div>
css:
.no-contact-info {
width: 400px;
}
.no-contact-info textarea {
width: 100%;
border-width: 1px;
border-style: solid;
border-right-color: #dbdfe6;
border-bottom-color: #e3e9ef;
border-left-color: #e7e8ed;
border-top-color: #abadb3;
z-index: 2;
}
.no-contact-info span {
display: block;
background:#FFFFC6 url(/media/icons/error.png) no-repeat 4px center;
padding: 2px 0 1px 24px;
color: #333333;
font-size: 12px;
font-weight: bold;
border: 1px solid #abadb3;
border-top-color: red;
width: 200px;
margin-top: -3px;
z-index: 1;
-webkit-border-bottom-right-radius: 4px;
-webkit-border-bottom-left-radius: 4px;
-moz-border-radius-bottomright: 4px;
-moz-border-radius-bottomleft: 4px;
border-bottom-right-radius: 4px;
}
view: http://jsfiddle.net/XurSz/
I want to push the "no contact info" span up slightly so that it covers the bottom border of the textarea... but the textarea keeps wanting to go overtop. How can I get around this?
The z-index property only affects elements that have been positioned. Adding position:relative; to the textarea and the span should do the trick.