Is it possible to achieve border radius curved inside through CSS3? - html

Is it possible to achieve something like above image?
So far I have tried following Code.
.greyParent {
height: 19px;
border-radius: 7px;
background: rgb(196, 196, 196);
}
.greyParent > .activeSlide {
background: rgb(0, 97, 188);
border-radius: 7px;
border-right: 1px solid #fff;
float: left;
width: 20%;
height: 19px;
position: absolute;
}
.greyParent > .activeSlide:first-child {
left: 0%;
z-index: 5;
}
.greyParent > .activeSlide + .activeSlide {
left: 16%;
z-index: 4;
}
<div class="col-xs-4 col-sm-2 col-md-2">
<span class="slideNo">1/5</span>
</div>
<div class="col-xs-8 col-sm-10 col-xs-9 progressImage">
<div class="greyParent">
<div class="activeSlide">
</div>
<div class="activeSlide">
</div>
</div>
</div>
I need to append .activeSlide div tag depending upon tab. Problem I am facing is as I append 5 .activeSlide div tags for fifth slide its not occupying entire parent div tag i.e div.greyParent. I understand that since i am doing position absolute and trying to move divs towards right, This is happening. But since i need to highlight the border of each partition i had to use position absolute. Can someone help me on this? Is there any solution for this?

You can use :before and :after pseudo elements to create this shape.
Draw circle of equal width and height on left/right corners of each list item respectively.
Add box-shadow of 1px or 2px to create border-effect between cells.
Output Image:
* {box-sizing: border-box;}
ul {
display: flex;
list-style: none;
padding: 0;
margin: 20px;
}
ul li {
position: relative;
background: gray;
height: 16px;
width: 60px;
}
ul li:before,
ul li:after {
box-shadow: 2px 0 0 #fff;
border-radius: 100%;
position: absolute;
background: gray;
height: 16px;
content: '';
width: 16px;
left: -8px;
top: 0;
}
ul li:first-child:before {
box-shadow: none;
}
ul li:after {
right: -8px;
left: auto;
}
ul li.active,
ul li.active:before,
ul li.active:after {
background: blue;
z-index: 1;
}
<ul>
<li class="active"></li>
<li class="active"></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

You can simply overlap the elements and give them the right width to make sure that they will be in the right place. You should also play with the left property to make them appear where you want.
The key should be in the properties you can see here:
.greyParent > div{
width: 25%;
}
.greyParent > div:nth-child(1){
left:0%;
width: 20%;
}
.greyParent > div:nth-child(2){
left:15%;
}
I have created this small jsfiddle which you can see as an example of what I mean

Try this, it's good ))
<div class="container">
<div class="title">
1/5
</div>
<div class="progress">
<span class="active"></span><span class="active"></span><span></span><span></span><span></span>
</div>
</div>
.container {
display: flex;
}
.container .title {
padding-right: 20px;
}
.container .progress {
display: flex;
width: 250px;
}
.container .progress span {
display: block;
height: 15px;
width: 20%;
background: gray;
border: solid 1px #fff;
border-radius: 7px;
margin-right: -15px;
}
.container .progress span.active {
background: blue;
}
.container .progress span:nth-child(1) {
z-index: 40;
}
.container .progress span:nth-child(2) {
z-index: 35;
}
.container .progress span:nth-child(3) {
z-index: 25;
}
.container .progress span:nth-child(4) {
z-index: 10;
}
JSfiddle example https://jsfiddle.net/5ph3uk94/

Why don't you just use 2 blue elements and 3 grey elements, instead of one big grey parent ?
<div class="col-xs-4 col-sm-2 col-md-2">
<span class="slideNo">1/5</span>
</div>
<div class="col-xs-8 col-sm-10 col-xs-9 progressImage">
<div class="parent">
<div class="activeSlide"></div>
<div class="activeSlide"></div>
<div class="diabledSlide"></div>
<div class="diabledSlide"></div>
<div class="diabledSlide"></div>
</div>
</div>

Related

how to control border bottom position

I hava a text logo (Doop) and i add border bottom but I can not control it.
how I can make the border bottom exactly in the center of the word(Doop) .I need this border to be exactly under the 2 (o)letters.
like this image >>i WANT LIKE THIS
.nav > .nav-header > .logo {
display: inline-block;
font-size: 22px;
color: hsl(0, 0%, 0%);
padding: 10px;
width: 20%;
text-align: center;
border-bottom: 2px solid rgb(223 35 44 / 92%);
}
<div class="nav">
<input type="checkbox" id="nav-check" />
<div class="nav-header">
<div class="logo">Doop</div>
</div>
AND THIS IMAGE IS MINE
I'ts not possible with border only to control it like you want.
You could use a pseudo element, for example ::after.
With a absolute, centered position and a little adjustment it should do what u want to.
.nav > .nav-header > .logo {
display: inline-block;
font-size: 22px;
color: hsl(0, 0%, 0%);
padding: 0 10px;
width: 20%;
text-align: center;
/* added this also, for pseudo absolute positioning */
position: relative;
}
.logo a {
text-decoration: none;
}
.logo::after {
content: '';
position: absolute;
left: 4px;
right: 0;
bottom: 0;
margin: auto;
height: 2px;
width: 18px;
background-color: rgb(223 35 44 / 92%);
}
<div class="nav">
<input type="checkbox" id="nav-check" />
<div class="nav-header">
<div class="logo">Doop</div>
</div>

how to make dots inherit the width of the image? (slick)

There is a block 225px. Inside you insert a picture large size (850px). And she goes outside.
It looks like this:
.content {display: inline-block;}
.column {float:right; width:225px;}
.slider {
border: 1px solid;
width: 220px;
padding: 5px;
}
.single-slide img {
width: auto;
}
<div class="content">
<div class="column">
<div class="slider single-slide">
<div><img src='https://s-media-cache-ak0.pinimg.com/736x/2c/d0/19/2cd0197c5eb8c1f84e81734f97e80cd3.jpg' /></div>
<div>to place the center of the image</div>
</div>
</div>
</div>
Using slick slider. I want to add dots to control the slider.
When I add the dots they are placed in the middle of the block. It's okay, I understand. But I want to place them in the center of the picture. How to do it?
UPD: The image goes beyond the block, that's right! And I need to do to the dots were at the center of the image, not the block
I see that your dots are in the center of the window.
To do this, your dots list must be inside a container with the image's width.
I think you should enlarge your slider or limit image's width with a max-width: 100%;
if you want to need image in box then change
.single-slide img { width: auto;}
to
.single-slide img { max-width: 100%;}
Updated: The inherit keyword specifies that a property should inherit its value from its parent element [ Source ]. and image can't be a parent element. see this example.
Here is a solution on based on inherit and position on your latest update.
See the html section I have added a class "img-holder" on div which hold the img and add a class "div_center" on div which contain text's.
img inherit width from its parent div class "img-holder". "img-holder" and "div_center" inherit width from parent div class slider.
N.B: if you set the img width auto text will always center of the div class slider.
.content {
display: inline-block;
}
.column {
float: right;
width: 225px;
}
.slider {
border: 1px solid #000;
width: 220px;
padding: 5px;
position:relative;
}
.img-holder {
width: inherit;
}
.img-holder img {
width: inherit;/*width auto default value. The browser calculates the width*/
}
.div_center {
position: absolute;
top: 50%;
left: 0;
right: 0;
text-align: center;
}
<div class="content">
<div class="column">
<div class="slider single-slide">
<div class="img-holder">
<img src='https://s-media-cache-ak0.pinimg.com/736x/2c/d0/19/2cd0197c5eb8c1f84e81734f97e80cd3.jpg' />
</div><!--./ img-holder -->
<div class="div_center">
to place the center of the image
</div><!--end of txt_center -->
</div><!--./ slider single-slide-->
</div><!--./ column -->
</div><!--./ content -->
Previous: Position absolute for slick-dots class but you dont set any relative position for that. so you need to add position relative to your slide div.
And make the image responsive. I have added responsive property for your image on css section and added border on li for clear view.
.content {display: inline-block;}
.column {float:right; width:225px;}
.slider {
border: 1px solid;
width: 220px;
padding: 5px;
position: relative;
}
.single-slide img {
max-width:100%;
display:block;
height:auto;
margin:0 auto;
}
.slick-dotted.slick-slider
{
margin-bottom: 30px;
}
.slick-dots
{
position: absolute;
top:50%;
left:0;
right:0;
display: block;
width: 100%;
padding: 0;
margin: 0;
list-style: none;
text-align: center;
}
.slick-dots li
{
position: relative;
display: inline-block;
width: 20px;
height: 20px;
margin: 0 5px;
padding: 0;
border:2px solid red;
cursor: pointer;
}
.slick-dots li button
{
font-size: 0;
line-height: 0;
display: block;
width: 20px;
height: 20px;
padding: 5px;
cursor: pointer;
right: 0;
bottom: 0;
left: 0;
color: transparent;
border: 0;
outline: none;
background: transparent;
}
.slick-dots li button:hover,
.slick-dots li button:focus
{
outline: none;
}
.slick-dots li button:hover:before,
.slick-dots li button:focus:before
{
opacity: 1;
}
.slick-dots li button:before
{
font-family: 'slick';
font-size: 12px;
line-height: 20px;
position: absolute;
top: 0;
left: 0;
width: 20px;
height: 20px;
content: '•';
text-align: center;
opacity: .25;
color: black;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.slick-dots li.slick-active button:before
{
opacity: .75;
color: black;
}
<div class="content">
<div class="column">
<div class="slider single-slide">
<div><img src='https://s-media-cache-ak0.pinimg.com/736x/2c/d0/19/2cd0197c5eb8c1f84e81734f97e80cd3.jpg' /></div>
<ul class="slick-dots">
<li class="active"><button></button></li>
<li><button></button></li>
<li><button></button></li>
</ul>
</div>
</div>
</div>

Creating Dot Leaders for Restaurant Menu

I'm trying to create a restaurant menu with dot leaders and I'm having trouble with this.
The format I'm looking for is the picture posted below.
Can someone please help me with this ?
HTML
<div class="dotted">
<ol>
<li>
<h2>Test</h2>
<p><span>Test 2</span><span class="price">$3.50(2) - $6.50(4)</span></p>
</li>
</ol>
</div>
CSS
p { margin: 0 0 -5px 0; }
li {
width: 100%;
position: relative;
margin-bottom: 1em;
border-bottom: 1px dotted #000;
list-style-type:none
}
span {
position: relative;
bottom: -1px;
padding: 0 1px;
background: #FFF;
}
span.price {
position: absolute;
right: 0; bottom: -6px;
}
Thanks in advance !
Wrap the first line of each group in a div that you make a flex container and use the following settings. The second line (ingredients) is outside of that container and can be a simple paragraph or DIV that has some bottom margin.
.linewrapper {
display: flex;
align-items: baseline;
}
.middle {
border-bottom: 1px dotted #aaa;
flex-grow: 1;
margin: 0 5px;
}
.ingredients {
color: #bbb;
margin-bottom: 1em;
}
<div class="linewrapper">
<div>
QUAIL
</div>
<div class="middle"></div>
<div>
9.9
</div>
</div>
<div class="ingredients">
stuff, stuff, stuff...
</div>
<div class="linewrapper">
<div>
SEA TROUT
</div>
<div class="middle"></div>
<div>
26.9
</div>
</div>
<div class="ingredients">
stuff, stuff, stuff...
</div>
Use a pseudo element with a dashed (or dotted or whatever) border to draw the dots and position it behind the text using z-index and give the text a background color so that the dots don't bleed through.
li {
display: flex;
justify-content: space-between;
position: relative;
align-items: baseline;
}
li:before {
border-bottom: 1px dashed #333;
content: '';
position: absolute;
bottom: 4px; left: 0; right: 0; top: 0;
z-index: -1;
}
span {
background: #fff;
padding: 0 .5em
}
<ul>
<li><span>Quail</span> <span>9.9</span></li>
<li><span>Quail</span> <span>9.9</span></li>
</ul>
body{
background: #fff;
}
.wrapper{
width:500px;
margin: 10px auto;
}
ul{
list-style:none;
padding: 0;
}
li{
width: 100%;
margin-bottom: 10px;
}
.line {
border-bottom: 1px dashed #000;
}
span{
float: right;
}
span, strong{
position:relative;
background: #fff;
z-index: 1;
top: 5px;
padding: 0 0 1px;
}
.description{
margin-top: 2px;
}
<div class="wrapper">
<ul>
<li><div class="line"><strong>My product</strong><span>Price</span></div><div class="description">My description</div></li>
<li><div class="line"><strong>My product</strong><span>Price</span></div><div class="description">My description</div></li>
<li><div class="line"><strong>My product</strong><span>Price</span></div><div class="description">My description</div></li>
</ul>
</div>

How to target two elements with one click?

I want to change the background-color of a box after clicking on it and at the same time create another box with pure CSS. I tried it with the target selector. But I only can manage to do one of them asks and not both at the same time.
Here is a DEMO of my try.
/* fonts */
p {
font-size: 10px;
}
#school::after,
#work::after {
font-size: 10px;
content: "Second box";
color: white
}
/* white boxes */
.panel {
height: 50px;
width: 50px;
background-color: white;
border: 1px solid #262626;
position: relative;
}
/* span (100%, 100%) inside the white-boxes */
.panel span {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
}
/* second-box */
.panel div {
display: none;
}
/* if white-box is targeted, this lets the second-box appear */
.panel div:target {
display: block;
height: 50px;
width: 50px;
background-color: blue;
border: 1px solid black;
border-radius: 4px;
position: absolute;
left: 70px;
}
/* for testing purposes */
.panel:active span {
background-color: black;
}
<p>White Boxes</p>
<div class="panel">
<a href="#school">
<span></span>
</a>
<div id="school"></div>
</div>
<div class="panel">
<a href="#work">
<span></span>
</a>
<div id="work"></div>
</div>
You can modify the presentation of any number of elements using the :target pseudo-class, so long as each one is nested within the element with the id which is :targeted:
/* fonts */
p {
font-size: 10px;
}
#school div::after, #work div::after {
font-size: 10px;
content: "Second box";
color: white
}
/* white boxes */
.panel {
height: 50px;
width: 50px;
background-color: white;
border: 1px solid #262626;
position: relative;
}
/* span (100%, 100%) inside the white-boxes */
.panel span {
position:absolute;
width:100%;
height:100%;
top:0;
left: 0;
}
/* second-box */
.panel a div {
display: none;
}
/* if white-box is targeted, this lets the second-box appear */
.panel a:target div {
display: block;
height: 50px;
width: 50px;
background-color: blue;
border: 1px solid black;
border-radius: 4px;
position: absolute;
left: 70px;
}
/* if white-box is targeted, this gives the box a blue background */
.panel a:target span {
background-color: blue;
}
/* for testing purposes */
.panel:active span {
background-color: black;
}
<p>White Boxes</p>
<div class="panel">
<a href="#school" id="school">
<span></span>
<div></div>
</a>
</div>
<div class="panel">
<a href="#work" id="work">
<span></span>
<div></div>
</a>
</div>
:target is only for one element at same time, because you can't target two anchors at same time. You need javascript or a css trick with :checked
Solution with pure css :checked
http://jsfiddle.net/KNG6n/78/
What I make:
<div class="panel">
<label>
<input type="checkbox">
<div></div>
</label>
</div>
CSS
label {
display:block;
position: relative;
width: 100%;
height: 100%;
}
label input {
visibility: hidden;
}
label input:checked + div {
display: block;
}
I see an answer was accepted already, but will post my solution if anyone else is interested.
I changed the location of the div to be before the link and added a css rule.
new code:
<p>White Boxes</p>
<div class="panel">
<div id="school"></div>
<a href="#school">
<span></span>
</a>
</div>
<div class="panel">
<div id="work"></div>
<a href="#work">
<span></span>
</a>
</div>
CSS added:
.panel div:target+a span{
background-color: black;
}
Demo:
http://jsfiddle.net/KNG6n/81/

Arrow right hidden at the back of main div

JSFIDDLE DEMO
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li>
1
</li>
<li class="active arrow_box">
2
</li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-3 col-md-10 col-md-offset-2 main">
Example content with tabs at top
</div>
</div>
</div>
CSS
.sidebar {
display: none; }
#media (min-width: 50em) {
.sidebar {
position: fixed;
top: 30px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px 0;
margin-right: 20px;
overflow: hidden;
background-color: #E5E5E5; } }
.nav-sidebar > li > a {
color: #262626;
font-size: 16pxpx;
padding: 24px 20px 24px 50px; }
.nav-sidebar > .active > a,
.nav-sidebar > .active > a:hover,
.nav-sidebar > .active > a:focus {
color: #30C4A3;
background-color: #333;
}
.nav-sidebar > li.active a:after {
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left: 10px solid re;
position: absolute;
bottom: -13px;
width: 0px;
left: 0;
margin-left: -10px;
z-index: 90000; }
.main {
overflow: hidden;
max-width: 1024px;
padding: 10px 0;
z-index: 0; }
#media (min-width: 50em) {
.main {
padding-right: 40px;
padding-left: 40px; }
}
.arrow_box {
background: #595959;
}
.arrow_box:after {
left: 100%;
top: 70%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
border-color: rgba(89, 89, 89, 0);
border-left-color: #595959;
border-width: 15px;
margin-top: -30px;
z-index: 4000;
}
Used Bootstrap Dashboard template example.
Tried omitting overflow-x but the scroll appeared and arrow could be only seen when scroll right. Tried adding padding or margin to give extra space next to li to display arrow, but the arrow still hid behind the main div. Also tried add z-index to header, sidebar, main but also not helping.
Updated
Forgot to clarify that the arrow I have got is only on sidebar. It should be outside the sidebar which is at the left side of content div. That's why I am trying to get arrow visible on the main div and it ends up being hidden.
Please help.
Just remove overflow: hidden; from .sidebar
Example here http://jsfiddle.net/u2Lbx4kc/3/
.sidebar {
position: fixed;
top: 30px;
bottom: 0;
left: 0;
z-index: 1000;
display: block;
padding: 20px 0;
margin-right: 20px;
background-color: #E5E5E5;
}
I didn't completely get your question but when the min-width is removed the li with class arrow seem to appear http://jsfiddle.net/u2Lbx4kc/1/
Add classes to ul to give it a width
HTML
<ul class="nav nav-sidebar col-sm-12 col-md-12">
<li> 1
</li>
<li class="active arrow_box"> 2
</li>
</ul>
Fiddle