put forms in the borders of an html block [closed] - html

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I would like to achieve something like this (Puttings the cercle and triangle in the borders of an html block).
Here's the css of my block:
.block {
color: red;
}
.cercle {
border-radius: 50%;
}
.triangle {
width: 0;
height: 0;
border-top: 60px solid transparent;
border-bottom: 60px solid transparent;
border-left: 60px solid red;
}

What you need to do is use absolute positioning, and instead of using borders use the CSS3's transform property.
Try this as an example:
.box {
padding: 50px;
border: 1px solid black;
display: inline-block;
}
.block {
background: red;
height: 100px;
width: 200px;
display: inline-block;
float: left;
position: relative;
border: 2px solid #880015;
}
.circle {
border-radius: 50%;
position: absolute;
width: 25px;
height: 25px;
background: red;
top: -12px;
right:-2px;
border: 2px solid #880015;
border-bottom: 0;
border-left: 0;
}
.triangle {
background: red;
position: absolute;
width: 20px;
height: 20px;
top: 5px;
right: -12px;
transform: rotate(45deg);
border: 2px solid #880015;
border-bottom: 0;
border-left: 0;
}
<div class="box">
<div class="block">
<div class="circle"></div>
<div class="triangle"></div>
</div>
</div>

Have a look at this article, it explains some of the features you are trying to achieve, but it involves solid images, rather than css only.
As a simpler solution, I suggest you to try with a DIV inside a DIV, and have all the content and the simple border in the inner div, and the custom elements (cercle, triangle) inside the outer div.

I made an example with an cicle, from here it should be easy enough to add other shapes.
html
<div class="wrapper">
<div class="square">
<div class="circle"></div>
</div>
</div>
css
.wrapper {
margin: 25px;
}
.square {
width: 300px;
height: 100px;
border: 5px solid red;
}
.circle {
width: 50px;
height: 50px;
border-radius: 50px;
background-color: pink;
position: absolute;
margin-left: 275px;
margin-top: -25px;
}
See https://jsfiddle.net/b8dthdwn/3/

You will need to use some HTML code first.
something like:
<div class="block">4
<div class="circle"></div>
<div class="triangle"></div>
</div>
And here is the CSS code:
.block {
background: red;
display: block;
width: 180px;
height: 90px;
}
.circle {
width: 20px;
height: 20px;
border-radius: 50%;
position: fixed;
top: 0.3px;
left: 170px;
z-index: 9999;
background: #000;
}
.triangle {
border-top: 10px solid transparent;
border-bottom: 10px solid transparent;
border-left:10px solid blue;
position:fixed;
top: 10px;
left: 187px;
}
You can use position: fixed to set the element position with top, left.
You can use z-index to make things to display above each other...
see example on jsbin

Related

CSS hover if element is covered by another? [duplicate]

Here is an example code that demonstrate the issue
.under {
position: absolute;
top: 10px;
left: 10px;
border: 2px solid blue;
width: 150px;
height: 150px;
}
.under:hover {
border: 10px solid green;
}
.over {
position: absolute;
z-index: 10;
top: 10px;
left: 10px;
width: 150px;
height: 150px;
border: 1px solid black;
}
<div>
<div class="under">
Hello!
</div>
<div class="over" data-comment="I am invisible">
</div>
</div>
When the mouse hovers over the over div, I want the under div to be aware of the hover event and, in this case, change the border accordingly.
However the over div is apparently intercepting the hover event. Can there be a pure css solution to pass the hover event to the under div?
Pointer events to the rescue!
Just set pointer-events: none; to the .over.
.under {
position: absolute;
top: 10px;
left: 10px;
border: 2px solid blue;
width: 150px;
height: 150px;
}
.under:hover {
border: 10px solid green;
}
.over {
position: absolute;
z-index: 10;
top: 10px;
left: 10px;
width: 150px;
height: 150px;
border: 1px solid black;
pointer-events: none;
}
<div>
<div class="under">
Hello!
</div>
<div class="over" data-comment="I am invisible">
</div>
</div>
Note, this will make the .over div ignore ALL pointer events, so javascript click handlers won't work
I would adjust the HTML structure and detect the hover on .over
.under {
position: absolute;
top: 10px;
left: 10px;
border: 2px solid blue;
width: 150px;
height: 150px;
}
.over:hover + .under {
border: 10px solid green;
}
.over {
position: absolute;
z-index: 10;
top: 10px;
left: 10px;
width: 150px;
height: 150px;
border: 1px solid black;
}
<div>
<div class="over" data-comment="I am invisible"></div>
<div class="under">Hello!</div>
</div>
Replace the order of the divs and set on hover to the over with ~ that targets the next sibling
.under {
position: absolute;
top: 10px;
left: 10px;
border: 2px solid blue;
width: 150px;
height: 150px;
}
.under:hover {
border: 10px solid green;
}
.over {
position: absolute;
z-index: 10;
top: 10px;
left: 10px;
width: 150px;
height: 150px;
border: 1px solid black;
}
.over:hover~div {
border: 10px solid green;
}
<div>
<div class="over" data-comment="I am invisible">
</div>
<div class="under">
Hello!
</div>
</div>

How to realize two collapsing circles in pure css3?

What i need to do is on image below:
I do not want use SVG at all. I think it is two divs with border-radius 50%. But how I merge them like on image? Can you solve this or give an advice?
This is a simpliest way to do it, may be you can improve it for your needs
#main {
width: 80px;
border-radius: 50%;
height: 80px;
border: 3px solid blue;
}
#background {
background: grey;
border-radius: 50%;
width: 100%;
height: 100%;
position: relative;
z-index: 2;
}
#small {
background: grey;
width: 30px;
border-radius: 50%;
height: 30px;
border: 3px solid blue;
margin-top: -30px;
margin-left: 50px;
}
<div id="main">
<div id="background"></div>
</div>
<div id="small"></div>

Pure CSS Responsive Trapezoid with borders and background colour

So i wanted to create a responsive trapezoid where you can apply a border and a background colour to it
I already created one using 3 div blocks but i cant get the border at the top of the trapezoid to stay inline when the width and height is changed
So my question is either.
can someone help me figure out how to keep the line at the top of the trapezoid in line with the left and right border
or if anybody knows of a different solution?
Here is my code....
.trapezoid-container{
position: relative;
margin-left: 100px;
width: 200px;
height: 200px;
}
.trapezoid {
background: green;
position: relative;
position:absolute;
content:"";
width: 70%;
height: 100%;
border-top: 5px solid black;
border-bottom: 5px solid black;
left: 20px;
}
.trapezoid:before {
background: green;
position:absolute;
content:"";
width: 60%;
height: 100%;
left: 63%;
border-right: 5px solid black;
border-bottom: 5px solid black;
transform: skew(20deg);
}
.trapezoid:after {
background: green;
position:absolute;
content:"";
width: 60%;
height: 100%;
left: -28%;
border-left: 5px solid black;
border-bottom: 5px solid black;
transform: skew(-20deg);
}
<div class="trapezoid-container">
<div class="trapezoid">
</div>
</div>
Thanks guys :)
A better solution found on How to draw a trapezium/trapezoid with css3? Which answers my question, thought id post it
#container {
position: relative;
margin-left: 200px;
width: 200px;
height: 200px;
}
.trapezoid {
position: relative;
width: 30%;
height: 50%;
background: red;
transform: perspective(2px) rotateX(1deg);
border: solid 4px black;
left: 20%;
top: 70%;
}
<div id="container">
<div class="trapezoid">
</div></div>

Creating a line with circle in the middle

So, I'm trying to achieve this result:
This is what I got when I tried: https://jsfiddle.net/wvdkmjge/
.container {
width: 100px;
height: 1px;
background-color: black;
}
.circle {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
background-color: transparent;
border: solid 1px black;
border-radius: 50%;
}
<div class="container">
<div class="circle">
</div>
</div>
Moreover, I want that I'll not see the border line on the circle. Any suggestions?
A small amendment to your code to position the elements and you get the effect you want to achieve.
.container {
width: 100px;
height: 1px;
background-color: black;
position: relative;
}
.circle {
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
background-color: white;
border: solid 1px black;
border-radius: 50%;
position: absolute;
top: -6px;
left: calc(50% - 5px);
}
.blue {
margin-top: 20px;
background: #3EB2EF;
}
.blue .circle {
background: #3EB2EF;
border-color: #3EB2EF;
}
<div class="container">
<div class="circle">
</div>
</div>
<div class="container blue">
<div class="circle">
</div>
</div>
If you want to position an element depending on its parent, use position:relative for the parent and then add position relative or absolute to the child. to center something in the middle, use margin:0 auto and if it has absolute positioning also add left:0; right:0;
https://jsfiddle.net/azizn/e4ev3awj/1/
.container {
width: 100px;
height: 1px;
background-color: blue;
position:relative;
}
.circle {
display:inline-block;
width: 10px;
height: 10px;
position: absolute;
background:blue;
left:0;
right:0;
margin:0 auto;
border-radius: 100%;
top:-4px;
}
<div class="container">
<div class="circle">
</div>
</div>
a bit late to answer, but this looks like a typical <hr/> that needs some makup.
/* restyle however your needs are hr and its pseudo elements , here only one is used */
hr {
color: turquoise;
border-width: 3px;
margin: 1em;
box-shadow: 0 0 5px gray;
}
hr:before {
content: '';
border-radius: 100%;
position: absolute;
height: 20px;
width: 20px;
background: turquoise;
left: 50%;
margin: -10px;
box-shadow: inherit
}
<hr/>
Try this:
.container {
width: 100px;
height: 1px;
background-color: black;
position: relative;
}
.circle {
position: absolute;
top: -5px;
left: 50%;
margin-left: -5px;
display: inline-block;
vertical-align: middle;
width: 10px;
height: 10px;
background-color: transparent;
border: solid 1px black;
border-radius: 50%;
}
<div class="container">
<div class="circle">
</div>
</div>
Fiddle
This uses a lot of different codes then above.
class:before and class:after
Hope this helps you!

How can I create a non-repeated outside border image?

I'm trying to figure out how to create a border image for separate divs in the screenshot, yet I can't seem to find a way to do so. Can anyone offer some guidance on how to make these outside border images work?
This is about as close as I can get it. No images required:
.has_tab {
border: 1px solid #e6e6e6;
border-left: none;
width: 33.33%;
height: 300px;
box-sizing: border-box;
display: block;
float: left;
position: relative;
text-align: center;
}
.has_tab:first-child {
border-left: 1px solid #e6e6e6;
}
/* the important bit... */
.has_tab:after {
content: "";
display: block;
width: 10px;
height: 100px;
background: #FFF;
border: 1px solid #e6e6e6;
border-left: none;
border-radius: 0 20px 20px 0;
position: absolute;
top: 50%;
margin-top: -50px;
right: -11px;
}
.has_tab:last-of-type:after {
display: none;
}
<div class="has_tab">Lorem ipsum</div>
<div class="has_tab">Lorem ipsum</div>
<div class="has_tab">Lorem ipsum</div>
Fiddle version
here is how i do it
first you need to cut this image
and then you can use it as background of after element
<div class="borderd-div"></div>
and the css:
.borderd-div{
height: 334px;
width:334px;
border: 1px solid #f1f1f1;
position: relative;
}
.borderd-div:after{
content:" ";
display: block;
position: absolute;
width: 20px;
height: 145px;
right:-19px;
top:83px;
background: url(Djyods1.png) no-repeat 0 0;
}