half circle links on edges/sides of page - html

I have the following code which makes 2 links in circles on the right and left of the page.
[class*="navigation"] .nav-previous,
[class*="navigation"] .nav-next {
position: fixed;
z-index: 999;
top: 50%;
text-align: center;
}
[class*="navigation"] .nav-previous {
left: 0px;
}
[class*="navigation"] .nav-next {
right: 0px;
}
[class*="navigation"] .nav-previous a,
[class*="navigation"] .nav-next a {
position: absolute;
display: inline-block;
font-size: 1.75em;
white-space: nowrap;
padding: 35px 40px;
color: #222;
border-radius: 50%;
background-color: #000;
}
[class*="navigation"] .nav-previous a {
transform: translateY(-50%) rotate(-90deg) translateX(50%) translateY(50%);
transform-origin: right 50%;
right: 2px;
}
[class*="navigation"] .nav-next a {
transform: translateY(-50%) rotate(90deg) translateX(-50%) translateY(50%);
transform-origin: left 50%;
left: 2px;
}
<div class="nav-previous">
<a>...</a>
</div>
<div class="nav-next">
<a>...</a>
</div>
I only want to show half circles with the link centered inside

Something like this?
Make a circle and then use position to place it half way down the div and half to the left/right
body {
background: #333;
height: 100vh;
}
.container {
background: #666;
height: 100%;
width: 100%;
position: relative;
}
.slider_nav {
background: #eee;
display: inline-block;
padding: 20px 20px 20px 40px;
border-radius: 50%;
position: absolute;
}
.prev {
padding: 20px 20px 20px 50px;
top: calc(50% - 20px);
left: -50px;
}
.next {
padding: 20px 50px 20px 20px;
top: calc(50% - 20px);
right: -50px;
}
<div class="container">
<div class="slider_nav prev"><span> < </span>
</div>
<div class="slider_nav next"><span> > </span>
</div>
</div>

Looks like you want to center of those circles to be on the edges of the pages. If so, you'll have to adjust for 50% of the width of you circles.
With '...' as your link, you can see in chrome that you have a total computed width of 101px.
Knowing that, you can just change your CSS like so...
.nav-previous { left: -50px; }
.nav-next { right: 50px;}

Related

Skewing both top and bottom of div

I am trying to skew both the top and bottom of a div to create a shape that I can then insert a background pattern to however, after a few hours of research I can't really come up with a solid solution. I'm nearly there in the sense that all I need to do is to skew the bottom but am looking for some help or guidance on doing so.
I would like the bottom to mirror the skew of the top. Any suggestions?
#test {
position: relative;
width: 100%;
height: 400px;
}
.bg {
width: 50%;
height: 800px;
-webkit-transition: all 300ms ease-in;
background: black;
border-radius: 80px 0px 0px 80px;
position: absolute;
right: 0;
top: 0;
-ms-transform: skewY(-9deg);
-webkit-transform: skewY(-9deg);
transform: skewY(-9deg);
}
<section id="test">
<div class="bg"></div>
</section>
Example of what I currently have
https://jsfiddle.net/3atsj1e5/
With some rotation and perspective you can do it:
.box {
margin-left: auto;
width: 200px;
height: 450px;
transform-origin: right;
transform: perspective(100px) rotateY(-10deg);
border-radius: 40px 0 0 40px;
overflow: hidden;
}
.box::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url(https://picsum.photos/id/1074/400/800) center/cover;
transform-origin:inherit;
transform: perspective(100px) rotateY(10deg);
}
body {
margin: 0;
background:#eee;
}
<div class="box"></div>

How to make slanted border stay in correct position across different screen sizes CSS3

I am trying to achieve the slanted left and right borders like the following design
I have been successful in achieving something that looks like it, especially the left and right slanted borders in screen size 1360px. Unfortunately, when the screen size is increased/decreased the left and right borders really mess up the layout. Is there a better way of doing this so that it is responsive and borders stay in correct places?
Here is how i'm coding the layout currently:
.f-col1 {
width: 15%;
float: left;
position: relative;
margin-top: -30px;
}
.f-col1::before {
content: " ";
width: 104%;
border-bottom: 1px solid #FFF;
position: absolute;
left: 0;
top: 0;
-ms-transform: rotate(22deg);
-webkit-transform: rotate(22deg);
transform: rotate(22deg);
margin-top: -8px;
}
.f-col2 {
width: 70%;
float: left;
border-top: 1px solid #FFF;
padding-top: 12px;
}
.f-col3 {
width: 15%;
float: left;
text-align: right;
position: relative;
margin-top: -50px;
}
.f-col3::before {
content: " ";
width: 104%;
border-bottom: 1px solid #FFF;
position: absolute;
left: 0;
top: 0;
-ms-transform: rotate(-22deg);
-webkit-transform: rotate(-22deg);
transform: rotate(-22deg);
margin-top: 12px;
margin-left: -4%;
}
I have made a JSFiddle for it:
https://jsfiddle.net/btmxus6t/
Also, live link where you can see the layout is displaying correctly in 1360px but messes up when screen size is changed:
http://revolutionarycoder.com/footer/index.html
If you wish to keep the same HTML structure:
Forcing the width to stay the same so we'll make sure the element doesn't change in size, including a static top/left/right property to force it into place, rest of the border will just fall off if not neccesary. Do note that this is a custom solution, and will not be very responsive if you decide to change stuff.
.f-col1::before {
content: " ";
width: 260px;
border-bottom: 1px solid #FFF;
position: absolute;
top: -20px;
right: -10px;
-ms-transform: rotate(22deg);
-webkit-transform: rotate(22deg);
transform: rotate(22deg);
}
.f-col3::before {
content: " ";
width: 265px;
border-bottom: 1px solid #FFF;
position: absolute;
left: -10px;
top: 0;
-ms-transform: rotate(-22deg);
-webkit-transform: rotate(-22deg);
transform: rotate(-22deg);
}
You can use rotating pseudo elements with heading:
body {
background: black;
color: white;
margin: 0;
}
h2 {
box-shadow: inset 0 -1px 0 0 white;
line-height: 4.5em;
margin: 0 10em;
position: relative;
text-align: center;
}
h2:before, h2:after {
bottom: 0;
box-shadow: inherit;
content: "";
height: 1px;
display: block;
position: absolute;
width: 10em;
}
h2:before {
right: 100%;
transform: rotate(20deg);
transform-origin: right bottom;
}
h2:after {
left: 100%;
transform: rotate(-20deg);
transform-origin: left bottom;
}
<h2>Title</h2>

Dynamic vertical text vertical align issue

I have some text which could be different on different pages. I need to make it align vertically middle. There is some problem because of less width for text.
.vertical-text-block {
width: 40px;
height: 100%;
position: absolute;
top: 0;
left: 0;
float: left;
background-color: grey;
}
.vertical-text {
display: block;
position: relative;
top: 50%;
white-space: nowrap;
font-size: 10px;
text-transform: uppercase;
transform: translateY(-50%);
transform: rotate(-90deg);
}
<div class="vertical-text-block">
<span class="vertical-text">ASHWANI SHARMA</span>
</div>
It should look like the image attached below:
I added right: 50%, transform-origin: right and removed transform: translateY()
.vertical-text-block {
width: 40px;
height: 100%;
position: absolute;
top: 0;
left: 0;
float: left;
background-color: grey;
background-image: linear-gradient(darkgrey 0%, darkgrey 50%, lightgrey 50%);
background-repeat: no-repeat;
}
.vertical-text {
display: block;
position: relative;
top: 50%;
right: 50%; /* 1 */
white-space: nowrap;
font-size: 10px;
text-transform: uppercase;
/*transform: translateY(-50%);*/ /* 2 */
transform: rotate(-90deg);
transform-origin: right; /* 3 */
}
<div class="vertical-text-block">
<span class="vertical-text">ASHWANI SHARMA</span>
</div>
i made a small change to the DOM and was able to achieve it,i.e centering the text , irrespective of its length .
Made a small change to the DOM .
<div class="vertical-text-wrap">
<div class="vertical-text-block">
</div>
<span class="vertical-text">American Leadership Index</span>
</div>
Added an extra wrapper , hope it is allowed.
.vertical-text-wrap {
position: absolute;
height: 100%;
margin: 0px 20px;
}
.vertical-text-block {
width: 40px;
height: 100%;
position: absolute;
top: 0;
left: 0;
float: left;
background-color: grey;
}
.vertical-text {
display: inline-block;
position: relative;
top: 50%;
left: -35%;
font-size: 10px;
text-transform: uppercase;
transform-origin: 50% 50%;
transform: translateY(50%) rotate(-90deg);
}
<div class="vertical-text-wrap">
<div class="vertical-text-block">
</div>
<span class="vertical-text">American Leadership Index</span>
</div>
Catch here is , when text becomes shorter , the left position of span.vertical-text has to be adjusted.
But hey , it is vertically centered :)
I think you can also do it this way http://codepen.io/Danstan/pen/QGWggO
Just add the translateX and translateY correctly on .vertical-text everything will be at the center
.vertical-text {
font-size:8px;
text-transform: uppercase;
position: absolute;
top: 50%;
left: 50%;
white-space: nowrap;
-webkit-transform: translateX(-50%) translateY(-50%) rotate(90deg);
transform: translateX(-50%) translateY(-50%) rotate(90deg); white-space: nowrap;font-size: 10px;}

Add pointer to the bottom of a div as a continuation of its background image

I'm looking for a way to stack divs, with a pointer leading into the next div that is a continuation of the previous div's background image.
I've looked around and I've seen some options, but in all of them the bottom div has to be a solid color.
For example: http://jsfiddle.net/nhqKb/
#container{
height: 300px;
background: url('http://farm8.staticflickr.com/7358/9532233404_58763bd668_b.jpg') no-repeat;
position: relative;
}
#one {
position: absolute;
width: 100px;
left: 0;
bottom: 0;
border-bottom: 20px solid green;
border-right: 20px solid transparent;
}
#two {
position: absolute;
left: 120px;
bottom: 0;
right: 0;
border-bottom: 20px solid green;
border-left: 20px solid transparent;
}
<div id="container">
<div id="one"></div>
<div id="two"></div>
</div>
Is there any way to implement this using divs with background images instead of solid colors?
You can use skewX and pseudo elements to make this.
#container {
background: url('https://images.unsplash.com/photo-1440635592348-167b1b30296f?ixlib=rb-0.3.5&q=80&fm=jpg&w=1080&fit=max&s=a029f986631f264fdbc8c0272cab9c40') no-repeat;
height: 300px;
position: relative;
overflow: hidden;
}
#one {
background-color: rgba(0, 0, 0, 0.3);
bottom: 0;
left: 0;
padding-bottom: 15px;
position: absolute;
width: 100%;
}
#one:before,
#one:after {
background-color: inherit;
bottom: 100%;
content: '';
padding-bottom: inherit;
position: absolute;
width: 50%;
}
#one:before {
right: 50%;
-ms-transform-origin: 100% 100%;
-webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
-ms-transform: skewX(45deg);
-webkit-transform: skewX(45deg);
transform: skewX(45deg);
}
#one:after {
left: 50%;
-ms-transform-origin: 0 100%;
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
-ms-transform: skewX(-45deg);
-webkit-transform: skewX(-45deg);
transform: skewX(-45deg);
}
HTML code:
<div id="container">
<div id="one"></div>
</div>

CSS Put arrows on each side of a Box(div)

Need help on how to put an arrow on each side of a box pointing outward.
I have the box and the basic CSS for an arrow I saw on another stack question.
Need help creating four arrows in that box
Im a java developer so this is not my cup of tea
Box:
#myBox {
width: 150px;
height: 150px;
background-color: grey;
border: 1px solid black;
}
/*Chevron*/
.Chevron {
position: relative;
display: block;
height: 50px;
/*height should be double border*/
}
.Chevron:before,
.Chevron:after {
position: absolute;
display: block;
content: "";
border: 25px solid transparent;
/*adjust size*/
}
/*Change four 'top' values below to rotate (top/right/bottom/left)*/
.Chevron:before {
top: 0;
border-top-color: #b00;
/*Chevron Color*/
}
.Chevron:after {
top: -50px;
/*adjust thickness*/
border-top-color: #fff;
/*Match background colour*/
}
<div id="myBox"></div>
<i class="Chevron"></i>
Since you are looking to interact with these shapes, you'd be better to go with a different approach to making your triangles, rather than a border hack.
.box {
height: 150px;
width: 150px;
background: lightgray;
position: relative;
}
.wrap {
position: absolute;
top: 0;
left: 25%;
height: 25%;
width: 50%;
overflow: hidden;
}
.touch {
position: absolute;
top: 0;
left: 50%;
height: 200%;
width: 200%;
transform: rotate(45deg);
transform-origin: top left;
background: gray;
cursor: pointer;
}
.wrap:nth-child(2) {
transform: rotate(90deg);
transform-origin: top left;
top: 25%;
left: 100%;
}
.wrap:nth-child(3) {
transform: rotate(180deg);
transform-origin: top left;
top: 100%;
left: 75%;
}
.wrap:nth-child(4) {
transform: rotate(-90deg);
transform-origin: top left;
top: 75%;
left: 0;
}
.touch:hover {
background: tomato;
}
<div class="box">
<span class="wrap"><span class="touch"></span></span>
<span class="wrap"><span class="touch"></span></span>
<span class="wrap"><span class="touch"></span></span>
<span class="wrap"><span class="touch"></span></span>
</div>
i have used the nth-child in order to position the arrows correctly. I have also needed to used a wrapper div like in this answer as the border-hack won't work on a hit-test.
Use Css triangle. Do you need something like this?
For each side, use the code below to make a triangle:
width: 0;
height: 0;
border-style: solid;
border-width: 100px 100px 100px 0;
border-color: transparent #007bff transparent transparent;
Here is a working demo.
I have managed to do this with 3 elements using CSS transforms and positioning. Is that what you were trying to achieve?
.container {
width: 100px;
height: 100px;
background: grey;
position: relative;
}
.container .triangles {
width: 70px;
height: 70px;
background: yellow;
transform: rotate(45deg);
position: absolute;
top: 15px;
left: 15px;
}
.container .triangles .box {
width: 50px;
height: 50px;
background: blue;
transform: rotate(-45deg);
position: absolute;
top: 10px;
left: 10px;
color: white;
}
<div class="container">
<div class="triangles">
<div class="box">
text
</div>
</div>
</div>