I have a layout where the border starts from middle of the image and merges with the below border
I have tried the following things:
Used background image as border but it cannot acheive the same thing.
I have ried to use :before & :after but unable to make it same like this.
Is there a way to make this??
You could playing around with the css position properties.
Hope it helps:
html
<main>
<section class="hero">
<div class="image-wrapper">
<img src="https://via.placeholder.com/450x150.png" alt="test image">
</div>
<div class="line-1"></div>
</section>
<section class="about">
<div class="content">
<h1>About us</h1>
<p>
Lorem ipsum dolor, sit amet consectetur adipisicing elit. Esse, sequi aspernatur inventore, ullam sapiente assumenda dignissimos dolorum voluptatibus nam est vel maxime cum quas. Blanditiis vel obcaecati voluptatibus qui alias.
</p>
</div>
<div class="line-2"></div>
</section>
</main>
and here is the css
:root{
--background-color: #ffffff;
--border: 2px solid green;
--border-radius: 8px;
--offset-left: 120px;
--offset-bottom: 30px;
}
main{
width: 90%;
max-width:1200px;
padding: 0 12px;
margin: 0 auto;
background-color: var(--background-color);
}
.hero{
position: relative;
}
.image-wrapper{
position: relative;
z-index:2;
}
.image-wrapper img{
width:100%;
height:auto;
}
.line-1{
position: absolute;
z-index:1;
width:calc(50% + var(--offset-left));
height:50%;
bottom: calc(var(--offset-bottom) * (-1));
left: calc(var(--offset-left) * (-1));
border-top: var(--border);
border-left: var(--border);
border-bottom: var(--border);
border-top-left-radius: var(--border-radius);
border-bottom-left-radius: var(--border-radius);
}
.about{
position: relative;
top: calc(var(--offset-bottom) / 2);
}
.content{
position: relative;
z-index:2;
text-align: center;
}
.content h1{
display: inline-block;
background-color: var(--background-color);
line-height:1;
padding: 0 10px;
font-size: 24px;
}
.content p{
text-align: left;
margin-top:30px;
}
.line-2{
position: absolute;
z-index:1;
width:calc(50% + var(--offset-left));
height:100%;
top: calc(var(--offset-bottom) / 2);
left: 50%;
border-top: var(--border);
border-right: var(--border);
border-top-right-radius: var(--border-radius);
}
Here is a working pen to play around.
Related
I'm new to web development and I'm having a hard time with CSS positioning.
I'm trying to make a div separator that looks like an axis: https://ibb.co/pfv8wcm
After resizing the window, the triangles I've added over the border lose their position: https://ibb.co/fS8707P
Code demo: https://liveweave.com/V4lTxA
How can I make it so the triangles maintain the same position on all viewports?
You can do this by adding "position-relative" to the container.
<div class="container-fluid info-div position-relative">
<div class="row">
<div class="col-12 col-sm-6 col-md-3">
<div class="box"></div>
</div>
<p class="col-12 col-sm-6 col-md-9">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolorem odio porro
obcaecati id ad illo
accusantium maxime, corrupti deleniti doloremque.
</p>
</div>
</div>
Then you need to modify the bottom arrow css from right:0% to left: 100%
.info-div:before {
bottom: -13px;
left: 100%;
border-top: 11px solid transparent;
border-left: 20px solid black;
border-bottom: 11px solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
And the top arrow:
.info-div:after {
top: -16px;
left: -13px;
border-left: 11px solid transparent;
border-right: 11px solid transparent;
border-bottom: 20px solid black;
content: " ";
height: 0;
width: 0;
position: absolute;
}
Instead of right:0 use left:100% which will make the arrow anchored to the outer right edge no matter what, same for top/bottom
body {
padding: 40px;
}
.box {
box-sizing: border-box;
width: 100px;
height: 100px;
background-color: darkgray;
}
.outer-div {
position: relative;
}
.info-div {
width: 50%;
border-bottom: 5px solid black;
border-left: 5px solid black;
margin: 50px;
}
.info-div:before {
bottom: -9px;
left: 100%;
border-top: 11px solid transparent;
border-left: 20px solid black;
border-bottom: 11px solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
}
.info-div:after {
bottom: 100%;
left: -9px;
border-left: 11px solid transparent;
border-right: 11px solid transparent;
border-bottom: 20px solid black;
content: " ";
height: 0;
width: 0;
position: absolute;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="outer-div">
<div class="container-fluid info-div">
<div class="row">
<div class="col-12 col-sm-6 col-md-3">
<div class="box"></div>
</div>
<p class="col-12 col-sm-6 col-md-9">Lorem ipsum dolor sit amet consectetur, adipisicing elit. Dolorem odio porro obcaecati id ad illo accusantium maxime, corrupti deleniti doloremque.
</p>
</div>
</div>
</div>
I have tried to make like this block but wasn't able to make as in the design. How can I make it? Can you help me? Here is desired block
and code I have tried:
.section-1 {
background: green;
height: 100px;
}
.section-2 {
display: flex;
align-items: center;
}
.col-img {
margin-top: -40px;
position: relative;
}
.col-img:after {
top: 40px;
position: absolute;
right: 100%;
width: 10px;
background: purple;
content: '';
bottom: 0;
}
.col-img img{
width: 100%;
vertical-align: top;
}
.section-2 .col {
width: 50%;
}
<div class="section-1">
</div>
<div class="section-2">
<div class="col">
<p>Lorem ipsum dolor, sit amet consectetur adipisicing elit. Harum voluptatem beatae quia facilis nobis, dolore quidem nostrum! Blanditiis eveniet dolor a, laudantium repudiandae rem commodi ea adipisci. Eius, obcaecati rerum.</p>
</div>
<div class="col col-img">
<img src="http://via.placeholder.com/650x650" alt="">
</div>
</div>
I would consider multiple background and some border like this like this:
body {
margin:0;
}
.box {
padding:40px calc(100% - 250px) 10px 20px;
box-sizing:border-box;
border-top:30px solid lightblue;
border-bottom:5px solid yellow;
height:350px;
background:
linear-gradient(120deg, lightblue 280px,transparent 280px)0 0/100% 40px no-repeat,
linear-gradient(120deg,white 250px,yellow 250px,yellow 280px,transparent 280px)0 0/100% 100% no-repeat,
url(https://lorempixel.com/1000/1000/) 0 0/cover no-repeat;
}
<div class="box">
lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum
</div>
Or more easier way with more element and some transformation:
body {
margin:0;
}
.box {
box-sizing:border-box;
border-top:30px solid lightblue;
border-bottom:5px solid yellow;
height:100vh;
display:flex;
background:url(https://lorempixel.com/1000/1000/) 0 0/cover no-repeat;
}
.content {
padding:20px 5px 0 30px;
box-sizing:border-box;
width:40%;
border-top:20px solid lightblue;
background:linear-gradient(yellow,yellow) 100% 0/10px 100% no-repeat;
transform:skew(-20deg);
transform-origin:top left;
background-color:#fff;
}
.content span{
display:inline-block;
transform:skew(20deg);
}
<div class="box">
<div class="content">
<span> lorem ipsum lorem ipsum lorem ipsum lorem ipsum</span>
</div>
</div>
You will want to use the CSS3 transform property, to skew your image. You can use either the skewX() or skewY() functions, or you can rotate().
.col-img {
transform:rotate(25deg);
}
Hope this helps.
I am keeping a circle inside a flex parent. the flex parent resize well. How can i resize the content inside the parent?
I tried to set the circle size by fluid, but fails too.
.parent {
display: flex;
justify-content: space-between;
border: 1px solid red;
align-items: center;
}
.child {
border-right: 1px solid gray;
width: 50%;
}
.last {
text-align: center;
}
.circle {
border: 1px solid gray;
border-radius: 50%;
width: 100px;
height: 100px;
display: inline-block;
margin: 0 auto;
}
/* my try but not works*/
/*
.circle{
border:1px solid gray;
border-radius:50%;
width:50%; not works!
height:50%; not works!
display:inline-block;
margin:0 auto;
}
*/
<div class="parent">
<div class="first child">
<p>Some text</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad voluptate laborum at soluta maiores molestiae minus pariatur voluptas tempore illo, alias, atque deserunt, ex architecto necessitatibus vel nobis fugit consequuntur.</p>
</div>
<div class="child last">
<div class="circle"></div>
</div>
</div>
use this
.circle {
border: 1px solid gray;
border-radius: 50%;
width: 40%;
padding-bottom: 40%;
height:auto;
display: inline-block;
margin: 0 auto;
}
.parent {
display: flex;
justify-content: space-between;
border: 1px solid red;
align-items: center;
}
.child {
border-right: 1px solid gray;
width: 50%;
}
.last {
text-align: center;
}
.circle {
border: 1px solid gray;
border-radius: 50%;
width: 40%;
padding-bottom: 40%;
height:auto;
display: inline-block;
margin: 0 auto;
}
/* my try but not works*/
/*
.circle{
border:1px solid gray;
border-radius:50%;
width:50%; not works!
height:50%; not works!
display:inline-block;
margin:0 auto;
}
*/
<div class="parent">
<div class="first child">
<p>Some text</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ad voluptate laborum at soluta maiores molestiae minus pariatur voluptas tempore illo, alias, atque deserunt, ex architecto necessitatibus vel nobis fugit consequuntur.</p>
</div>
<div class="child last">
<div class="circle"></div>
</div>
</div>
I have taken two divs say "Panel1" and "Panel2" where Panel1 is having property affix (hard-coded in HTML so have to forcefully apply position:relative on other screen sizes) attached to it in HTML with col-md-3 and Panel2 is col-md-8.
Now the problem is I have to apply left value of around 25% for my Panel2 to align as per Panel1 otherwise it goes beneath it but doing this has broken responsiveness. The design breaks on all other screen sizes and just violates the purpose of using bootstrap for responsive design. (I have to use header and footer from original design and creating a dashboard based on that).
What would be the approach to design without writing and managing screen sizes again manually so that, all I use is bootstrap and design should work on low rez screens.
HTML:
<!-- DASHBOARD SECTION STARTS (Bootstrap Components) -->
<div class="container-fuild dash-panel">
<div class="row">
<div class="col-md-3 left-panel" data-spy="affix">
<ul class="dash-items">
<li class="dash-li"><a class="list-links" href="index.html"><!-- <img class="profile-image" src="../images/ad.jpg" alt=""> -->Profile</a></li>
<li class="dash-li"><a class="list-links" href="my-ads.html">My Advertisements</a></li>
<li class="dash-li"><a class="list-links" href="fav-ads.html">My Favouraite Advertisments</a></li>
<li class="dash-li"><a class="list-links" href="reported-ads.html">Reported Advertisments</a></li>
</ul>
</div>
<div class="col-md-8 right-panel">
<img class="profile-image" src="../images/ad.jpg" alt="">
<div class="profile-info">
<p class="profile-detail-para"><label>Name: </label>John Doe</p>
<p class="profile-detail-para"><label>Email: </label>doejohn#xyz.com</p>
<p class="profile-detail-para"><label>Summary: </label><span>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nesciunt natus dicta assumenda, velit quae officia accusantium explicabo similique possimus veniam illo, dolor delectus saepe quis in eveniet voluptatem adipisci, repudiandae.</span><span>Veritatis at saepe labore explicabo, voluptas asperiores unde accusantium tempore harum, numquam porro doloremque aliquid assumenda. Maiores voluptates aliquid dicta autem commodi eveniet voluptas exercitationem ut, hic laborum laudantium veritatis.</span></p>
<p class="profile-detail-para">
<a class="profile-edit" href="edit-info.html">Edit info <i class="fa fa-edit"></i></a>
</p>
</div>
</div>
</div>
</div>
<!-- DASHBOARD SECTION ENDS -->
Overridden CSS
/* Contains custom css for dashboard */
#import url(https://fonts.googleapis.com/css?family=Montserrat|Dosis);
#import url(https://fonts.googleapis.com/css?family=Open+Sans);
body{
background: #1D1D1D none repeat scroll 0px 0px;
}
.dash-panel{
padding-top: 1%;
padding-bottom: 1%;
height: 480px;
}
.left-panel{
background: #000;
margin-right: 4%;
height: 100%;
left: 5%;
}
.dash-items{
list-style: none;
margin-left: -10%;
}
.dash-li{
margin-top: 2px;
padding: 3%;
}
.dash-li:hover{
background: #3F3030;
}
.list-links{
text-decoration: none !important;
color: #F0B101;
font-family: 'Montserrat', sans-serif;
}
.list-links-profile{
text-decoration: none !important;
color: #F0B101;
font-family: 'Montserrat', sans-serif;
margin-left: -20%;
}
.right-panel{
background: #000;
padding: 2%;
margin-left: 32.4%;
}
.right-panel-2{
background: #000;
padding: 2%;
left: 24%;
}
.profile-image{
max-width: 100%;
width: 100px;
height: 100px;
border-radius: 100%;
float: left;
}
.profile-info{
float: left;
margin-left: 2%;
font-family: 'Dosis', sans-serif;
background: #1D1D1D;
width: 80%;
padding: 2%;
}
.profile-detail-para{
margin-bottom: 2%;
}
.set-BG{
background: #1D1D1D;
}
.listing-image{
width: 180px;
}
.profile-edit{
background: #D7DFE6;
padding: 1%;
color: #000;
}
/* Status */
.pub{
color: #369536;
}
.pen{
color: #D13D3D;
}
/* Status Ends */
.edit-profile{
font-family: 'Open Sans', sans-serif;
padding: 2%;
}
.text-area{
background-color: transparent;
border: 1px solid #464646;
border-radius: none !important;
color: #B8B8B8;
height: 40px;
padding: 5px 10px;
width: 100%;
box-shadow: none;
}
input[type=file]{
background: #000;
}
.submit-btn{
width: 15%;
background: #000;
border: 1px solid #E1B101;
}
#media (max-width: 768px) {
.left-panel {
position: relative;
left: 1.5%;
width: 34%;
float: left;
}
.right-panel{
left: 0%;
float: right;
}
.right-panel-2{
left: 0%;
}
.profile-info{
left: 0%;
}
}
#media (max-width: 480px) {
.left-panel {
position: relative;
left: 1.5%;
float: none;
}
.right-panel{
left: 0%;
float: none;
}
.right-panel-2{
left: 0%;
}
.profile-info{
left: 0%;
}
}
/* #media (max-width: 900px) {
.left-panel {
position: relative;
left: 1.5%;
}
.right-panel{
left: 0%;
}
.right-panel-2{
left: 0%;
}
.profile-info{
left: 0%;
}
} */
I've been making this website for school and I thought i'd figure out how parallax scrolling works. So i've started with the simpelest tutorial to be precise this one. After doing this I placed my navigation bar in. I remember this worked fine at the time but after working allot on the responsiveness I didn't check back and now I can't click on the links anymore.
This is my html:
<div id="group2" class="parallax_group">
<!-- <div class="parallax_layer parallax_layer-back">
background
</div> -->
<div class="parallax_layer parallax_layer-base">
<div id="nav" class="nav">
<ul>
<li><a class="active" href="#">Home</a></li>
<li>Over ons</li>
<li>Wat leveren wij?</li>
<li>Contact</li>
<li>Demo</li>
</ul>
</div>
<div class="section group">
<div class="col span_1_of_3">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quibusdam id nam, necessitatibus at odit nobis vitae, dolor sequi sunt doloremque minima, debitis. Sed debitis possimus esse soluta mollitia est culpa.</p>
</div>
<div id="middle" class="col span_1_of_3">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Qui autem impedit, a, error accusantium soluta molestias quidem quo totam beatae eligendi sint, modi voluptatem nemo fugiat recusandae ullam consequatur nihil?</p>
</div>
<div class="col span_1_of_3">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Provident voluptatibus, quaerat nostrum ullam distinctio praesentium! Nemo eveniet provident id, tenetur cumque natus, quas porro possimus maiores, minus amet laboriosam ea?</p>
</div>
</div>
</div>
</div>
And this is my css:
* {
padding: 0;
margin: 0;
}
body {
text-align: center;
}
h1{
display: inline-block;
font-family: 'Raleway', sans-serif;
color: white;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
p{
display: inline-block;
font-family: 'Raleway', sans-serif;
color: black;
}
header {
z-index: 5;
line-height: 100vh;
}
header .parallax_layer-back {
background: url(sample.jpg);
background-size: contain;
background-repeat: no-repeat;
}
#group2 {
z-index: 3;
}
#group2 .parallax_layer-base {
background-color: #dbdbdb;
}
.parallax {
perspective: 300px;
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
}
.parallax_layer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax_layer-base {
transform: translateZ(0px);
z-index: 4;
}
.parallax_layer-back {
transform: translateZ(-300px) scale(2);
z-index: 3;
height: 150vh;
}
.parallax_layer-deep{
transform: translateZ(-600px) scale(3);
z-index: 2;
background-color: #dbdbdb;
}
.parallax_group {
position: relative;
height: 100vh;
transform-style: preserve-3d;
/*transform: translate3d(700px, 0, -800px) rotateY(30deg);*/
}
/*Columns*/
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float:left;
margin: 1% 0 1% 1.6%;
}
.col:first-child { margin-left: 0; }
/* GROUPING */
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
}
.group {
zoom:1; /* For IE 6/7 */
}
/* GRID OF THREE */
.span_3_of_3 {
width: 100%;
}
.span_2_of_3 {
width: 66.1%;
}
.span_1_of_3 {
width: 32.2%;
}
#middle{
border-top: 0px;
border-bottom: 0px;
border-right: 1px;
border-left: 1px;
border-style: solid;
}
/*navigation*/
.nav {
position: sticky;
top: 0px;
height: 100px;
width: 100%;
z-index: 30;
font-family: 'Raleway', sans-serif;
font-size: 20px;
background-color: #dbdbdb;
}
.nav ul {
list-style-type: none;
margin-left: 0;
padding-top: 40px;
font-size: 25px;
font-family: 'Raleway', sans-serif;
line-height: 0;
z-index: 30;
}
.nav li {
display: inline-block;
margin-left: 15px;
padding-bottom: 25px;
z-index: 30;
}
a:link {
color: #2F649B;
font-family: inherit;
}
a:visited {
color: #2F649B;
}
a:hover {
color: #6D92B9;
text-decoration: none;
}
a:active {
color: #26507C;
text-decoration: none;
}
footer {
position: sticky;
bottom: 0px;
height: 100px !important;
line-height: 100px;
width: 100%;
}
I know it's allot of code but I have no idea what it could be so i went and gone ahead and gave you everything.
edit: The other html parallax group:
<!DOCTYPE html>
<html>
<head>
<title>Squirel WebDesign</title>
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="stylesheet" type="text/css" href="handheld.css" media="screen and (max-device-width: 480px), screen and (max-width: 480px)">
</head>
<body>
<div class="parallax">
<header class="parallax_group">
<div class="parallax_layer parallax_layer-base">
<h1>i'm a bloody big header preferably with a squirel</h1>
</div>
<div class="parallax_layer parallax_layer-back">
</div>
<div class="parallax_layer parallax_layer-deep">
</div>
</header>