I want to make a shape in html that has cutoff corners and with a borderline around the shape.
I can make cut-off shapes without a border like so:
html:
<div class="cut-off"></div>
css:
.cut-off{
position:relative;
top:400px;
left:400px;
height:155px;
width:200px;
background:red;
}
.cut-off:after{
position:absolute;
bottom:0px; right:-20px;
content:".";
text-indent:-999px; overflow:hidden;
display:block;
width:0px; height:0px;
border-top: 20px solid green;
border-right: 20px solid transparent;
}
.cut-off:before{
position:absolute;
top:0; right:-20px;
content:"#";
text-indent:-999px; overflow:hidden;
display:block;
background:blue;
width:20px; height:135px;
}
Jfiddle here
Now i want a border that goes around the shape.
How should i do that?
I want a shape that is something like this:
Filled with a color.
By altering your html structure a little bit, I could make this
<div class="cut-off"></div>
<div class="cut-off2"></div>
.cut-off{
position: relative;
width: 300px;
height: 150px;
border-bottom: 80px red solid;
border-right: 80px transparent solid;
}
.cut-off2{
position: absolute;
z-index: -1;
top:0;
left: 0;
width: 305px;
height: 150px;
border-bottom: 82px blue solid;
border-right: 80px transparent solid;
}
p{
position: absolute;
left: 0;
bottom:-40px;
}
Basically it adds another div under the existing one. For the cuttof effect it plays with border dimensions.
EDIT: I also provided a way of including content in the area.
Try this out:
<div class="cut-off">content</div>
.cut-off{
position:relative;
height:155px;
width:200px;
background:red;
}
.cut-off:after{
position:absolute;
bottom:0px; right:-20px;
content:".";
text-indent:-999px; overflow:hidden;
display:block;
width:0px; height:0px;
border-top: 20px solid green;
border-right: 20px solid transparent;
}
.cut-off:before{
position:absolute;
top:0; right:-20px;
content:"#";
text-indent:-999px; overflow:hidden;
display:block;
background:blue;
width:20px; height:135px;
}
By the way, I found this example in the following page (and therefore I do not claim that the code is mine): http://www.wahnbriefe.net/web-design/css-cut-off-corners
I'm not really sure if this is what you're looking for, but I think you could use the CCS3 border-radius attribute in order to achieve it. Perhaps it is worthwhile taking a look at it. Maybe you can try something like the follwing:
<div class="cut-off">
<p class="text">Simple text</p>
</div>
.cut-off{
position: relative;
width: 300px;
height: 150px;
border: 1px solid #7A7764;
border-radius: 0 75px 0 0;
}
.text {
margin: 15px;
}
Related
i have a problem like this.
#relative{
position:relative;
width:100%;
height:100%;
text-align:center;
}
button{
margin:10px auto;
width:200px;
height:auto;
border:1px solid;
border-radius:5px;
}
#absolute{
position: absolute;
top: 0;
left:0;
height: 250px;
width: 100%;
border: solid 1px #000000;
color: blue;
font-weight: bold;
padding-top: 60px;
/*opacity:0;*/
}
button:hover{
background-color:#eed5a4;
}
<div id="relative">
<button>
Hover me if you can.
</button>
<div id="absolute">
Absolute its me dude!!<br>
If me >> opacity:0<br>
Button still cant be hover.
</div>
</div>
Any solution for this, and i dont know to use the good english language
Note : button keep like this, do not change the position absolute too.
- my english so bad :(
Add position:relative; and a higher z-index than that of the #absolute div to the button itself, like so:
HTML
<button id="relative-button">Hover me if you can.</button>
CSS
#absolute { z-index:1 }
#relative-button { position:relative; z-index:2 }
replace button css like this
button {
border: 1px solid;
border-radius: 5px;
height: auto;
margin: 10px auto;
position: relative; /* newly added */
width: 200px;
z-index: 9; /* newly added */
}
Thanks #daniel lisik, you are awesome people. Extraordinary
#relative{
position:relative;
width:100%;
height:100%;
text-align:center;
}
button{
position:relative;
z-index:5;
margin:10px auto;
width:200px;
height:auto;
border:1px solid;
border-radius:5px;
}
#absolute{
position: absolute;
z-index:1;
top: 0;
left:0;
height: 250px;
width: 100%;
border: solid 1px #000000;
color: blue;
font-weight: bold;
padding-top: 60px;
/*opacity:0;*/
}
button:hover{
background-color:#eed5a4;
}
<div id="relative">
<button>
Hover me if you can.
</button>
<div id="absolute">
Absolute its me dude!!<br>
If me >> opacity:0<br>
Button still cant be hover.
</div>
</div>
The speech bubble right here gets placed on top of the div, how would I get it to be placed on the left or right of the div?
How would the rotations look and how would the placement work?
CSS:
<style>
.speech-bubble {
position:relative;
margin-top: 5px;
float:right;
color: black;
background-color:white;
padding: 7px;
border: 1px solid;
border-color:red;
border-radius: 4px;
}
.speech-bubble:before,
.speech-bubble:after {
content: " ";
display:block;
position:absolute;
top:-8px;
left:25px;
z-index:2;
width: 1px;
height: 0;
overflow:hidden;
border: solid 10px transparent;
border-top: 0;
border-bottom-color:#FFF;
}
.speech-bubble:before {
top:-10px;
z-index:1;
border-bottom-color:red;
}
</style>
<div class="speech-bubble">
awe
fawefawefawef<br/>
aawefawef
</div>
CodePen Link
You will have to change the values in the following lines:
.speech-bubble:before,
.speech-bubble:after {
top:-8px;
left:25px;
}
.speech-bubble:before {
top:-10px;
}
Or use this generator.
I am trying to add a bottom arrow image at the the top of every div section of my web page.I want the bottom arrow to be centered as in http://jirungu2012.wix.com/firebrandoption2
Each section has a different bottom arrow color
You could use an image or you could use CSS. Here is a quick example with the green span line to show that it is centred. In future please show your attempts in your question and add more detail.
div{
width:500px;
height:200px;
background-color:blue;
position:absolute;
top:0;
left:0;
}
div::before{
content:" ";
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #f00;
position:absolute;
left:50%;
transform:translateX(-50%)
}
span{
position:absolute;
left:50%;
width:1px;
height:100%;
background-color:green;
}
<div>
<span></span>
</div>
.solidArea{
width:100%;
height:20px;
background-color:lightblue;
margin: ;
}
.arrow-down {
width: 0;
height: 0;
border-left: 20px solid transparent;
border-right: 20px solid transparent;
border-top: 20px solid #fff;
}
<div class="solidArea">
<div align="center">
<div class="arrow-down "></div>
</div>
</div>
There you go..
Not sure how to describe it, so here's a pic:
This is what I've tried so far, but the span is not visible.
.border{
border-bottom: 1px solid #666;
width:400px;
position:relative;
}
.border span{
border-bottom:4px solid red;
display:inline-block;
width:50px;
position:absolute;
left:48%;
bottom:-4px;
}
Ok, try this:
HTML:
<div class="border"></div>
CSS:
.border{
width:400px;
height: 1px; /* instead of border */
background: #666;
position:relative;
}
/* pseudo-element instead of span for cleaner HTML */
.border:before {
content: '';
border-bottom:4px solid red;
display:inline-block;
width:50px;
position:absolute;
left:48%;
top:-2px; /* instead of bottom, go top by half the height */
}
Replace bottom by margin :
.border span{
border-bottom:4px solid red;
display:inline-block;
width:50px;
position:absolute;
left:48%;
margin-bottom:-2px;
}
try this
css
div.container{border-top:solid 1px red;padding:0px;}
div.inside{height:100%;width:100%;border-top:2px solid red;margin:0px;}
html
content
i havent tested but it should work
I am trying to style setup a section of a website with a pattern running to each side of certain pieces of text. You an see a screenshot that I took from the PSD file here --> http://screencast.com/t/84RCLRdSZT with red arrows pointing to the areas in question that I am finding difficult to solve.
Any idea how to go about this?
Here is what I am starting with:
<div class="box">
<h2>Some text here</h2>
</div>
and the css:
.box {
width:400px;
height:200px;
text-align:center;
background:yellow;
}
h2:after,h2:before{
content:"";
border:5px double purple;
}
here is the fiddle --> http://jsfiddle.net/HerrLoop/g63LB/1/
As you can see, the stripes are vertical, instead of horizontal as you can see in my initial screenshot.
This isn't quite perfect and requires you set a fixed width on the before/after elements (best I can think of is to use JavaScript if responsive is required), but here goes:
h2{
display:inline-block;
vertical-align:middle;
}
h2:after,
h2:before{
content:"";
margin:0px 20px;
border:1px solid #000;
border-left: 0px;
border-right:0px;
height:5px;
width:50px;
display:inline-block;
vertical-align:middle;
}
http://jsfiddle.net/daCrosby/g63LB/2/
Edit
This is a little bit more responsive, but still gets kind of cut off at small sizes and looks disproportional at others:
.box {
width:50%;
overflow:hidden;
}
h2{
display:inline-block;
vertical-align:middle;
width:100%;
white-space:nowrap;
}
h2:after,
h2:before{
content:"";
margin:0px 20px;
border:1px solid #000;
border-left: 0px;
border-right:0px;
height:5px;
width:20%;
display:inline-block;
vertical-align:middle;
}
http://jsfiddle.net/daCrosby/g63LB/3/
Try the solution described here: http://kizu.ru/en/fun/legends-and-headings/
The quick demo:
h2{
overflow-x: hidden;
white-space: nowrap;
text-align: center;
}
h2:before, h2:after {
content: "";
border: solid #000;
border-width: 1px 0;
height: 5px;
width: 50%;
display: inline-block;
vertical-align: middle;
}
h2:before { margin: 0 .5em 0 -50%; }
h2:after { margin: 0 -50% 0 .5em; }