I need to create a fluid shape with a cut off corner and a border. The shape needs to be able to sit on an unknown background. This in itself isn't an issue but I also need the background of this element/s to be semi-opaque.
Here's what I have so far...
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: pink;
}
.sidebar-widget {
border: 1px solid #44AAAB;
border-right: none;
border-bottom: none;
position: relative;
padding: 15px 0 0 15px;
margin-bottom: 20px;
}
.sidebar-widget .inner {
position: relative;
padding: 15px 0 0 15px;
left: -15px;
top: -15px;
background: #f2f2f2;
}
.sidebar-widget .inner:before {
content: "";
width: 100%;
height: 15px;
background: #f2f2f2;
border: 1px solid #44AAAB;
border-right: none;
border-top: none;
position: absolute;
left: -1px;
bottom: -16px;
}
.sidebar-widget .inner .content:after {
content: "";
width: 15px;
height: 100%;
background: #f2f2f2;
border: 1px solid #44AAAB;
border-left: none;
border-bottom: none;
position: absolute;
right: -16px;
top: -1px;
}
.corner {
width: 22px;
height: 22px;
border-right: 1px solid #44AAAB;
background: #f2f2f2;
position: absolute;
right: 4px;
bottom: 4px;
transform: rotate(45deg);
z-index: 1;
}
.sidebar-widget.trans-bg .inner,
.sidebar-widget.trans-bg .inner:before,
.sidebar-widget.trans-bg .inner .content:after,
.trans-bg .corner {
background: rgba(0,0,0,0.5);
}
<div class="sidebar-widget">
<div class="corner"></div>
<div class="inner">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tellus felis, faucibus id velit eget, auctor tristique ex. Pellentesque id dolor risus. Donec tincidunt, nisl id laoreet tristique, ligula magna placerat mi, id congue magna diam ut sem. Aenean ornare eros nec sapien porta, laoreet venenatis est lobortis.
</div>
</div>
</div>
<div class="sidebar-widget trans-bg">
<div class="corner"></div>
<div class="inner">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tellus felis, faucibus id velit eget, auctor tristique ex. Pellentesque id dolor risus. Donec tincidunt, nisl id laoreet tristique, ligula magna placerat mi, id congue magna diam ut sem. Aenean ornare eros nec sapien porta, laoreet venenatis est lobortis.
</div>
</div>
</div>
This approach works when the element has solid background but as you can see the square element used to create the cut-off corner is clearly visible when using a semi-opaque background. Can anyone think of a way to get around this?
JSFiddle version
For anyone who is interested here is how I ended up doing it.
Wrap the .corner in another element with overflow: hidden;
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
background: pink;
}
.sidebar-widget {
border: 1px solid #44AAAB;
border-right: none;
border-bottom: none;
position: relative;
padding: 15px 0 0 15px;
margin-bottom: 20px;
}
.sidebar-widget .inner {
position: relative;
padding: 15px 0 0 15px;
left: -15px;
top: -15px;
background: #f2f2f2;
}
.sidebar-widget .inner:before {
content: "";
width: 100%;
height: 15px;
background: #f2f2f2;
border: 1px solid #44AAAB;
border-right: none;
border-top: none;
position: absolute;
left: -1px;
bottom: -16px;
}
.sidebar-widget .inner .content:after {
content: "";
width: 15px;
height: 100%;
background: #f2f2f2;
border: 1px solid #44AAAB;
border-left: none;
border-bottom: none;
position: absolute;
right: -16px;
top: -1px;
}
.corner-mask {
width: 15px;
height: 15px;
position: absolute;
right: 0;
bottom: 0;
overflow: hidden;
}
.corner {
width: 22px;
height: 22px;
border-right: 1px solid #44AAAB;
background: #f2f2f2;
position: absolute;
right: 4px;
bottom: 4px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
z-index: 1;
}
.sidebar-widget.trans-bg .inner,
.sidebar-widget.trans-bg .inner:before,
.sidebar-widget.trans-bg .inner .content:after,
.trans-bg .corner {
background: rgba(0,0,0,0.5);
}
<div class="sidebar-widget">
<div class="corner-mask">
<div class="corner"></div>
</div>
<div class="inner">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tellus felis, faucibus id velit eget, auctor tristique ex. Pellentesque id dolor risus. Donec tincidunt, nisl id laoreet tristique, ligula magna placerat mi, id congue magna diam ut sem. Aenean ornare eros nec sapien porta, laoreet venenatis est lobortis.
</div>
</div>
</div>
<div class="sidebar-widget trans-bg">
<div class="corner-mask">
<div class="corner"></div>
</div>
<div class="inner">
<div class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tellus felis, faucibus id velit eget, auctor tristique ex. Pellentesque id dolor risus. Donec tincidunt, nisl id laoreet tristique, ligula magna placerat mi, id congue magna diam ut sem. Aenean ornare eros nec sapien porta, laoreet venenatis est lobortis.
</div>
</div>
</div>
JSFiddle version
You can use another element inside .corner, see the example below:
<style>
.corner, .corner_inner { /* added .corner_inner to your styles */
width: 22px;
height: 22px;
border-right: 1px solid #44AAAB;
background: #f2f2f2;
position: absolute;
right: 4px;
bottom: 4px;
transform: rotate(45deg);
z-index: 1;
}
.trans-bg .corner {background: transparent} /* overwrite the background above */
.trans-bg .corner_inner { /* set background and position for inner element */
width: 11px;
height: 11px;
right: -1px;
bottom: 0;
background: rgba(0,0,0,0.5);
}
</style>
<div class="sidebar-widget trans-bg">
<div class="corner">
<div class="corner_inner"></div>
</div>
...
</div>
http://jsfiddle.net/6Lyph6zj/3/
I've edited your styles, some properties are overwritten and can be removed. I mean you can understand better what changes I've made.
Related
I am trying to make the following banner in bootstrap. The demo of the banner can be seen her.
I cannot figure out how I can make this in bootstrap 3, and where to start. Should the row and col be like this for at start, or should it only be one row? Is it transform there is making the slant line on the image?
<div class="container-fluid">
<div class="row">
<div class="col-md-6">Text here</div>
<div class="col-md-6"><img src="https://image-here.jpg"></div>
</div>
</div>
The original code for the banner is:
.widget-about {
position: relative;
overflow: hidden;
padding: 0;
margin: 0;
}
.widget-about .tg-container {
position: absolute;
left: 50%;
top: 0;
height: 100%;
max-width: 1200px;
transform: translateX(-50%);
}
.widget-about .tg-container .about-content-wrapper {
position: absolute;
left: 0;
top: 0;
width: 50%;
height: 100%;
background: #f9f9f9; }
.widget-about .tg-container .about-content-wrapper .about-block {
position: absolute;
top: 50%;
left: 0;
transform: translateY(-50%);
z-index: 999; }
.widget-about .tg-container .about-content-wrapper .about-block .about-title {
font-size: 28px;
margin: 0;
text-transform: uppercase; }
.widget-about .tg-container .about-content-wrapper .about-block .about-title a {
color: #454545; }
.widget-about .tg-container .about-content-wrapper .about-block .about-sub-title {
color: #00a9e0;
margin: 10px 0;
font-size: 16px;
text-transform: capitalize; }
.widget-about .tg-container .about-content-wrapper .about-block .about-content {
color: #737373;
font-size: 14px;
margin-top: 20px; }
.widget-about .tg-container .about-content-wrapper:before {
content: "";
position: absolute;
width: 1000%;
height: 100%;
background: #f9f9f9;
left: -1000%;
top: 0; }
.widget-about .tg-container .about-content-wrapper:after {
background: #f9f9f9 none repeat scroll 0 0;
content: "";
height: 2000px;
position: absolute;
right: 650px;
top: 50%;
transform: rotate(70deg) translateY(-50%);
width: 2000px;
z-index: 9; }
.about-img {
/* margin: 0; */
}
.about-img img {
width: 100%;
display: block; }
<section id="estore_about-3" class="widget widget-about clearfix">
<div class="section-wrapper">
<figure class="about-img">
<img width="1600" height="310" src="https://demo.themegrill.com/estore/wp-content/uploads/sites/49/2016/02/about.jpg">
</figure>
<div class="tg-container">
<div class="about-content-wrapper">
<div class="about-block">
<h3 class="about-title">
BEST STORE THEME </h3>
<h4 class="about-sub-title">Multicolor & Multipurpose Woocommerce Theme</h4>
<div class="about-content">
Aenean ipsum felis, luctus in hendrerit eget, varius non lacus. Duis et aliquet lacus. Quisque iaculis congue facilisis. Aenean eu dolor vestibulum, lobortis ligula eu, rhoncus diam. Etiam et efficitur augue. Etiam vehicula sem quis risus elementum euismod. Sed id mattis sapien. Ut lacinia aliquam massa eget efficitur. Suspendisse fermentum eget leo suscipit faucibus. Morbi
</div>
</div>
</div><!-- .about-content-wrapper -->
</div><!-- .tg-container -->
</div>
</section>
Edit
You won't be able to exactly match without some custom css, so here's the my minimum using mostly bootstrap classes and some custom css to get the desired styles (little slant) and expected responsive behavior.
.custom-bg {
background-size: cover;
background-position: center right;
min-height: 100px !important;
}
.custom-content:after {
background: transparent;
border-top: 250px solid transparent;
border-bottom: 0px solid transparent;
border-left: 80px solid #f7f7f7;
content: '';
height: 100%;
position: absolute;
right: -80px;
top: 0;
width: 0;
z-index: 10;
}
.custom-row {
margin: 0 !important;
}
#media (max-width: 991px) {
.custom-bg {
background-position: top right;
}
.custom-row {
flex-direction: column-reverse;
}
.custom-content:after {
display: none
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row custom-row">
<div class="col-lg-7 col-sm-12">
<div class="p-3 custom-content">
<h3>Best Store Theme</h3>
<h5 class="text-primary">Multicolor & Multipurpose Woocommerce Theme</h5>
<p>Aenean ipsum felis, luctus in hendrerit eget, varius non lacus. Duis et aliquet lacus. Quisque iaculis congue facilisis. Aenean eu dolor vestibulum, lobortis ligula eu, rhoncus diam. Etiam et efficitur augue. Etiam vehicula sem quis risus elementum euismod. Sed id mattis sapien. Ut lacinia aliquam massa eget efficitur. Suspendisse fermentum eget leo suscipit faucibus. Morbi</p>
</div>
</div>
<div class="col-lg-5 col-sm-12 custom-bg" style="background-image: url('https://demo.themegrill.com/estore/wp-content/uploads/sites/49/2016/02/about.jpg')">
</div>
</div>
How would you split a div into 2 parts (both containing horizontal text) by a diagonal line?
e.g. see this where 1 has a rectangular background image and 2 has text with a background color:
You can do it with a pseudo element rotated like this:
body {
background-color: #00bcd4;
}
.main {
margin: 50px;
overflow: hidden;
position: relative;
width: 350px;
}
.image {
background: url(https://s-media-cache-ak0.pinimg.com/564x/ca/9b/ca/ca9bca4db9afb09158b76641ea09ddb6.jpg) center center no-repeat;
background-size: cover;
height: 200px;
}
.text {
background-color: white;
padding: 30px;
position: relative;
}
.text > div {
position: relative;
z-index: 1;
}
.text:before {
content: "";
background-color: white;
position: absolute;
height: 100%;
width: 120%;
top: -20px;
left: -10%;
transform: rotate(5deg);
z-index: 0;
}
<div class="main">
<div class="image"></div>
<div class="text">
<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae gravida purus. Ut quis elit magna. Fusce et mattis sapien. Sed venenatis magna ut ligula facilisis, eget vulputate neque aliquet. Nulla lacinia condimentum leo non aliquet. Integer
et enim dapibus, tempor ipsum non, fringilla enim. Cras semper fermentum dolor, at pharetra dolor ornare sit amet. Morbi eu dictum orci, tincidunt pretium nisi. Sed finibus vulputate eleifend. Nulla ac leo facilisis, fermentum tellus in, feugiat
risus. Curabitur in sem luctus, pellentesque justo nec, aliquet velit. Nam euismod est sit amet ultrices consequat.
</div>
</div>
</div>
As per my knowledge, its cannot be done using any single CSS property directly, you will have to hack it via using pseudo-elements, or best approach will be do it using SVG
.container {
width: 90%;
margin: 0 auto;
}
.box {
width: 200px;
height: 150px;
text-align: center;
}
.box-1 {
background: #ff6347;
}
.box-2 {
background: #0ff;
}
.box-2:before {
display: inline-block;
margin: 0;
margin-top: -30px;
margin-left: -30px;
content: '';
border: 30px solid transparent;
border-right: 200px solid #0ff;
}
<div class="container">
<div class="box box-1"></div>
<div class="box box-2">
TITLE 1
</div>
</div>
.container {
width: 400px;
margin: 0 auto;
}
.box {
width: 200px;
height: 150px;
text-align: center;
float: left;
}
.box-1 {
background: #ff4500;
}
.box-2 {
background: #0ffab9;
}
.box-2:before {
display: inline-block;
margin: 0;
margin-left: -101px;
margin-top: -1px;
position: absolute;
content: '';
width: 0;
height: 0;
border-bottom: 151px solid #0ffab9;
border-left: 30px solid transparent;
}
<div class="container">
<div class="box box-1">
</div>
<div class="box box-2">
TITLE 1
</div>
</div>
Not sure how else to title this (if someone else has a better title feel free to edit the post) but essentially the clients wants responsive aarced lines along the top one pink and one purple as shown here in the screenshot:
Im currently accomplishing this (since an image is not responsive enough) using the element (pink) a ::before (the purple area) and an ::after (the pink line) Now i need an image slider to peek in below it but currently its being covered by the layers before it:
it needs to look like this mockup:
Is there any way i can acomplish this?
html:
<div class="topbar">
<div class="container">
<div class="logo"></div>
</div>
</div>
<div class="container firstbelow"></div>
css:
.topbar {
position: relative;
width: 100%;
height: 200px;
background: pink;
overflow: hidden;
z-index: 5;
}
.topbar:after {
position: absolute;
content: "";
left: -20%;
top: 50%;
width: 140%;
height: 300px;
background: rgb(250, 244, 255);
background-repeat: no-repeat;
background-position: center top;
border-radius: 100% 0 0 0 / 90%;
border-top: 5px solid #ff88bb;
z-index: 5;
}
.topbar:before {
position: absolute;
content: "";
left: -20%;
top: 42%;
width: 140%;
height: 150%;
background: #8855bb;
box-shadow: inset 10px -10px 5px -10px #000;
border-radius: 80% 0 0 0 / 60%;
-ms-transform: rotate(-3deg);
-webkit-transform: rotate(-3deg);
transform: rotate(-1deg);
z-index: 5;
}
.firstbelow {
margin-top: -95px;
height: 300px;
background-image: url(../images/slider/Commercial.png);
z-index: 4
}
(Note: Yes, i am aware that the ::after element has a white background. if it does not then the pink and putple layers show through and i still cannot see the slider image)
you may also use a container in a fixed position and set a padding-top or margin top to the content that it may also slide underneath.
You can also play with gradient , shadow and radius to draw your shape:
snippet below or codepen
header {
position: fixed;
left: 0;
width: 100%;
}
header div {
background: linear-gradient(165deg, #FFC0CB 31%, transparent 31.5%), linear-gradient(175deg, #FFC0CB 41%, transparent 41.5%), linear-gradient(179.5deg, #FFC0CB 32.5%, transparent 33%);
padding-top: 30px;
position: relative;
top: 0;
left: 0;
right: 0;
width: 100%;
z-index: 1;
height: 220px;
}
header:after {
z-index: -1;
content: '';
display: block;
height: 200px;
pointer-events: none;
left: 0px;
width: 100%;
top: 120px;
margin: -55px 0 0 0;
border-radius: 1500px 0 0 0 / 150px 0 0 0;
box-shadow: inset 50px 80px 0 -70px #FFC0CB, inset 20px 90px 0 -70px #8855BB, inset 30px 80px 0 -50px #FF88BB;
position: absolute;
box-sizing: border-box;
border-top: solid #FFC0CB 0;
}
body {
margin: 0 auto;
width: 800px;
max-width:100%;
}
nav {
width: 800px;
max-width:100%;
margin: auto;
display: flex;
justify-content: space-between;
}
nav img {
border-radius: 50% / 3em;
box-shadow: 0 0 5px;
height: 80px;
width: 80px;
}
nav a {
vertical-align: top;
margin: 0 1em;
color: gray
}
main {
padding-top: 160px;
color: #FF88BB;
text-shadow: 1px 1px gray;
text-align: justify
}
h1,
h2,
h3,
pre {
color: gray;
display: table;
border-bottom: solid #FFC0CB;
padding: 0 0.25em;
line-height: 0.8em;
}
pre {
background: lightgray;
}
li {
color: #8855BB
}
<header>
<div>
<nav>
<a href="#">
<img src="http://lorempixel.com/90/100/food/8" />
</a>
<span> link
link
link
link
link
link
</span>
</nav>
</div>
</header>
<main>
<h1>HTML Ipsum Presents</h1>
<p><strong>Pellentesque habitant morbi tristique</strong> senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. <em>Aenean ultricies mi vitae est.</em> Mauris
placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, <code>commodo vitae</code>, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis
tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis.</p>
<h2>Header Level 2</h2>
<ol>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ol>
<blockquote>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis
elit sit amet quam. Vivamus pretium ornare est.</p>
</blockquote>
<h3>Header Level 3</h3>
<ul>
<li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</li>
<li>Aliquam tincidunt mauris eu risus.</li>
</ul>
<pre><code>
#header h1 a {
display: block;
width: 300px;
height: 80px;
}
</code></pre>
</main>
Put the topbar as an absolute element at the top of the page
.topbar {
top: 0;
left: 0;
position: absolute;
width: 100%;
height: 200px;
background: pink;
z-index: 5;
height: <static_dimension>;
}
I have a header which has a background which is set to background-attachment: fixed;, but this is making a white strip appear at the top of the page at certain scroll positions (The background is blurred, so the strip is also blurred, but it is still visible).
This is how it currently looks; there is that white glow sort of thing at the top, which is that strip that I am talking about
The code I have right now is this (If you run the snippet, please view it full screen, since I haven't made it mobile-compatible yet): Edit on Codepen
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Open Sans', sans-serif;
font-weight: 300;
font-size: 1.02em;
}
html,
body {
height: 100%;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: 1.5em;
line-height: 2em;
}
.container {
margin: 0 auto;
width: 80vw;
}
blockquote {
box-sizing: content-box;
position: relative;
margin: 0 auto;
display: block;
padding-left: 30px;
font-size: 1.5em;
font-style: italic;
color: #4a413c;
border-left: 7px solid rgba(74, 65, 60, 0.5);
quotes: "“" "”" "‘" "’";
padding-bottom: 1.75em;
}
blockquote::before {
position: absolute;
top: 0.55em;
left: -0.5em;
content: open-quote;
line-height: 0.2em;
font-style: normal;
font-size: 5em;
font-family: 'Adobe Caslon Pro', serif;
color: #4a413c;
}
blockquote::after {
position: absolute;
right: 0;
bottom: 0;
content: attr(data-author);
font-style: italic;
font-size: 0.75em;
color: 4a413c;
}
/* Header */
header {
position: relative;
width: 100%;
height: 60%;
padding: 50px 100px;
text-align: center;
overflow: hidden;
color: white;
font-size: 1.5em;
margin-bottom: 50px;
}
header.no-margin {
margin-bottom: 0;
}
header .container {
width: 100%;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%)
}
header .container h1 {
position: relative;
display: inline-block;
font-weight: 300;
}
header .container h1::after {
position: absolute;
bottom: 1px;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%);
content: '';
width: 80%;
height: 2px;
border-bottom: 2px solid white;
}
header .container a {
color: inherit;
font-size: inherit;
text-decoration: inherit;
-webkit-transition: all 0.75s 0s;
transition: all 0.75s 0s;
border-bottom: 2px solid transparent;
}
header .container nav ul {
list-style: none;
}
header nav ul li {
display: inline-block;
padding: 5px 30px;
}
header nav ul li a:hover {
border-bottom: 2px solid white;
}
header .container p {
width: 40%;
margin: 0 auto;
}
/* Header Background */
.header::before {
position: absolute;
top: 0;
left: 0;
z-index: -100;
content: '';
display: block;
min-height: 100vh;
width: 100%;
background-image: -webkit-radial-gradient(center ellipse, rgba(0, 0, 0, 0.3) 27%, rgba(0, 0, 0, 1) 100%), url(https://placeimg.com/640/480/any);
background-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.3) 27%, rgba(0, 0, 0, 1) 100%), url(https://placeimg.com/640/480/any);
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
background-attachment: fixed;
-webkit-filter: blur(7px) saturate(90%) brightness(120%) contrast(125%);
filter: blur(7px) saturate(90%) brightness(120%) contrast(125%);
-webkit-transform: scale(1.2);
transform: scale(1.2);
}
section.quote {
position: relative;
min-height: 40vh;
}
section.quote blockquote {
position: absolute;
width: 50%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.section.latest {
display: block;
margin: 0 auto;
clear: both;
}
div.latest {
padding: 10px;
position: relative;
width: 25vw;
height: 25vw;
overflow: hidden;
float: left;
background-size: cover;
background-position: center center;
background-attachment: scroll;
margin: 5px;
}
div.latest::after {
content: '';
clear: both;
}
<header class="header no-margin">
<div class="container">
<nav>
<ul>
<li>Artwork</li>
<li>Blog</li>
<li>Social</li>
<li>Comission</li>
<li>Contact</li>
</ul>
</nav>
<h1>Blog Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</header>
<div class="container">
<section class="quote">
<blockquote data-author="Pablo Picasso">
The meaning of life is to find your gift. The purpose of life is to give it away.
</blockquote>
</section>
<main>
<section class="section latest">
<h2>Latest Artwork</h2>
<div class="latest" style="background-image: url(https://placeimg.com/640/480/any);">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vehicula tempus neque ut faucibus. Integer quam arcu, dictum in mattis nec, dapibus sed libero. Nam condimentum convallis elit eget placerat. Proin consectetur enim nulla, non hendrerit ante
bibendum in. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam commodo velit sapien, vitae tempor neque faucibus et.
</div>
<div class="latest" style="background-image: url(https://placeimg.com/641/450/any);">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vehicula tempus neque ut faucibus. Integer quam arcu, dictum in mattis nec, dapibus sed libero. Nam condimentum convallis elit eget placerat. Proin consectetur enim nulla, non hendrerit ante
bibendum in. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam commodo velit sapien, vitae tempor neque faucibus et.
</div>
<div class="latest" style="background-image: url(https://placeimg.com/653/470/any);">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vehicula tempus neque ut faucibus. Integer quam arcu, dictum in mattis nec, dapibus sed libero. Nam condimentum convallis elit eget placerat. Proin consectetur enim nulla, non hendrerit ante
bibendum in. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam commodo velit sapien, vitae tempor neque faucibus et.
</div>
</section>
<section class="section">
<h2>Latest Posts</h2>
</section>
</main>
</div>
To see the strip, scroll down until there is only a small but of the header on the screen.
The strip goes when you change background-attachment: fixed; to background-attachment: scroll;, but I want to keep it fixed.
I feel like I'm overlooking something, but I cannot think of anything that might be causing this, so what is causing this issue, and how can I fix it?
I am new to parallax CSS (it is on my list-o-things-to-grok), but I think the problem is that you are translating the header (and therefore its background) down as the user scrolls the content up (this is what gives the parallax effect). Perhaps if you size the header so its top is above the viewport, as it scrolls down you won't see the white.
There's a problem in my code attached below:
The img with id listItemProfile stays always in middle no matter what padding I set, I though it might due to there's some padding in its parent, but I couldn't find any, any thoughts?
Thanks in advance!
<!DOCTYPE html>
<html>
<head>
</head>
<style type="text/css">
.accordionOm {
position: relative;
padding: 10px 0 10px 30px;
margin: 0;
font: 300 18px 'Oswald', Arial, Helvetica, sans-serif;
cursor: pointer;
}
.accordionOm:hover {
color: #000;
}
.accordionOm:before,
.accordionOm:after {
content: "";
position: absolute;
background: #333;
display: inline-block;
}
.accordionOm:before {
width: 20px;
height: 2px;
left: 0;
top: 22px;
}
.accordionOm:after {
width: 2px;
height: 20px;
left: 9px;
top: 13px;
transition: transform .5s;
transform: rotate(0);
}
.accordionOm.opened:after {
transform: rotate(90deg);
}
.accordionOm + div {
border-left: 4px solid #999;
padding: 0 15px;
margin-left: 8px;
font: 13px 'Open Sans', Arial, Helvetica, sans-serif;
color: #666;
}
* {
font-family: Arial, Verdana, sans-serif;
color: #665544;
text-align: center;}
body {
width: 100%;
margin: 0 auto;
}
#trailBar{
margin-left: 35px;
margin-right: 35px;
margin-top: 25px;
margin-bottom: 25px;
height: 180px;
background: -webkit-linear-gradient(right, #31a7de, #31a7de 35px, white 35px, white);
border: transparent;
border-radius:0.25em;
}
p.trailTextTop{
padding-top: 25px;
padding-left: 25px;
padding-right: 60px;
padding-bottom: 25px;
font-size: large;
}
p.trailTextBot{
padding-left: 25px;
padding-right: 60px;
padding-bottom: 25px;
font-size: large;
}
.left { float: left; }
.right { float: right; }
p { overflow: hidden; }
.panel-group .list-group {
margin-bottom: 0;
}
.panel-group .list-group .list-group-item {
border-radius: 0;
border-left: none;
border-right: none;
}
.panel-group .list-group .list-group-item:last-child {
border-bottom: none;
}
.panel-body{
background: #efefef;
}
#listItem{
position: relative;
height: 200px;
background: #efefef;
}
#listItemProfile{
position: absolute;
height: 80px;
width: 80px;
padding-top: 60px;
padding-bottom: 60px;
padding-left: 35px;
}
#listItemTitle{
}
#listItemSubtitle{
}
#listItemInfo{
}
#listItemArrow{
}
</style>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h4 class="accordionOm opened">
<div id="listItem">
<img id = "listItemProfile" src="images/Portrait.png">
<div id="listItemTitle">
</div>
<div id="listItemSubtitle">
</div>
<div id="listItemInfo">
</div>
<div id="listItemArrow">
</div>
</div>
</h4>
<div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
<div id="trailBar">
<p class="trailTextTop"><span class='left'>Good morning, I just start my first day trip. Happy pedal!</span></p>
<p class="trailTextBot"><span class='left'>Time 7:20</span><span class='right'>45 Miles</span></p>
</div>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
<h4 class="accordionOm">Accordian heading</h4>
<div>
<p>Lorem ipsum dolor sit amet, adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa
quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
</div>
</body>
<script>
$('.accordionOm').next().hide();
$(".opened").next().show();
$('.accordionOm').click(function() {
if ($(this).hasClass("opened") == true) {
$(this).next().slideUp("slow");
$(this).removeClass('opened');
} else {
$(".opened").next().slideUp("slow");
$(".opened").removeClass("opened");
$(this).addClass('opened');
$(this).next().slideDown("slow");
}
});
</script>
</html>
Hi now define this css
#listItemProfile {
position: absolute;
height: 80px;
width: 80px;
/* padding-top: 60px; */
/* padding-bottom: 60px; */
/* padding-left: 35px; */
left: 50%;
top: 50%;
margin-left: -40px; // your total width img / 2
margin-top: -40px; // your total height img /2
}
You can use this css given below :
#listItemProfile {
position: absolute;
height: 80px;
width: 80px;
left: 50%;
top: 50%;
margin-left: -40px;
margin-top: -40px;
}
try with margin-left , margin-right
Example
.class-name{
margin-left:10px;
margin-right:50px;
}