I have seen the gradient borders with radius work on css-tricks with this particular code snippet.
<div class="fem">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Nostrum neque debitis at ad fugit, esse sequi rem ab consequatur id sint veniam ex quam adipisci. Ab itaque officia atque id!
</p>
</div>
.fem {
padding: 1rem;
position: relative;
background: #000;
color: white;
border-radius: 8px;
}
.fem:before {
content: "";
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
width: calc(100% + 10px);
height: calc(100% + 10px);
z-index: -1;
border-radius: 12px;
background: linear-gradient(130deg,#ff7a18,#af002d 41.07%,#319197 76.05%);
}
I have tested this code on jsbin and it seems to be working perfectly fine.
Now, I'm working on a tailwind application and this same code isn't working for me.
I feel that some of the base styles might be causing this erratic behaviour. I can't seem to figure out how to correct it.
Here is the link to tailwind play
On tailwind, I'm seeing invisible gradient borders
<div class="main">
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia ullam fugit quaerat voluptates culpa dolores id
veritatis suscipit quo officia minus, ex totam velit praesentium explicabo, exercitationem blanditiis numquam
doloremque?
</div>
<style>
.main {
background-color: black;
max-width: 80%;
padding: 1rem;
position: relative;
color: white;
border-radius: 8px;
}
.main:before {
content: "";
position: absolute;
top: -5px;
left: -5px;
right: -5px;
bottom: -5px;
width: calc(100% + 10px);
height: calc(100% + 10px);
z-index: -1;
border-radius: 12px;
background: linear-gradient(130deg, #ff7a18, #af002d 41.07%, #319197 76.05%);
}
</style>
Related
I have an interesting situation.
What I want to achieve is that, instead of spreading from top to bottom, the animation will spread from the middle.
I also want to achieve this without any help of JS/jQuery.
Appreciate your thoughts :)
* {
border: 0;
margin: 0;
padding: 0;
}
h1 {
margin-top: 30px;
text-align: center;
line-height: 30px;
transition: line-height 0.3s ease-in-out;
}
h1:hover {
line-height: 60px;
}
<h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti doloribus beatae laboriosam aspernatur magni, molestias possimus, rerum voluptates dolorum aliquam est soluta animi inventore ut at eius voluptatum quod omnis.</h1>
Just wrap this text in a wrapper, give it a height, position the text in center vertically and it will work. View it in full page.
* {
border: 0;
margin: 0;
padding: 0;
}
h1 {
margin-top: 30px;
text-align: center;
line-height: 30px;
transition: line-height 0.3s ease-in-out;
}
h1:hover {
line-height: 60px;
}
.wrapper {
height: 400px;
display: flex;
align-items: center;
}
<div class="wrapper">
<h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti doloribus beatae laboriosam aspernatur magni. consectetur adipisicing elit. Corrupti doloribus beatae laboriosam aspernatur magni.</h1>
</div>
Easy, Just use the line-height in this case, or you can use flex as well.
The only issue is the height of the container, in this case I use the 120px, that is the max height that the text can expand, you can also use height:100%; or height:100vh on the
* {
border: 0;
margin: 0;
padding: 0;
}
h1 {
display:inline-block;
text-align: center;
line-height: 30px;
transition: line-height 0.3s ease-in-out;
vertical-align:middle;
}
h1:hover {
line-height: 60px;
}
.container-mod{
margin-top: 30px;
height:100vh;
}
.container-mod:before{
content:"";
vertical-align:middle;
display: inline-block;
height:100%;
}
<div class="container-mod"><h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Corrupti doloribus beatae laboriosam aspernatur magni, molestias possimus, rerum voluptates dolorum aliquam est soluta animi inventore ut at eius voluptatum quod omnis.</h1></div>
I have a little question due to position of background image in my footer.
As You can see on the picture, my current background image (green dotted line with ball - it is svg image) is placed in the middle if the footer.
I would like to place it in the position of the red line, staying there while resizing window.
Code of it is:
footer{
position: relative;
/* START OF IMAGE BG */
&:before{
content: "";
position: absolute;
display: block;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url("/wp-content/themes/company/static/img/line.svg");
-moz-background-size:90%;
background-size:90%;
background-repeat: no-repeat;
}
/* END OF IMG BG */
padding: rem-calc(45 20);
#media #{$medium-up}{
padding: rem-calc(85);
}
background-color: $bluedark;
color: $white;
min-height: rem-calc(500);
p{
font-size: rem-calc(12);
#media #{$medium-up}{
font-size: rem-calc(16);
}
font-weight: 300;
&.section-header{
text-transform: uppercase;
font-weight: 600;
}
&.bold{
font-weight: 600;
}
&.green{
color: $green;
}
}
.social-media{
img{
display: inline-block;
margin: rem-calc(0 5 20 5);
max-height: rem-calc(20);
#media #{$medium-up}{
max-height: rem-calc(40);
}
}
}
.underline{
margin-top: rem-calc(50);
border-top: 1px solid $bluegrey;
padding-top: rem-calc(20);
.logo{
float: left;
width: rem-calc(200);
height: rem-calc(45);
background: url("/wp-content/themes/company/static/img/logo_light.svg");
background-size: contain;
background-repeat: no-repeat;
}
select{
float: right;
}
}
}
And html is:
<footer>
<div class="line"></div>
<div class="flex">
<div class="row">
<div class="large-3 columns">
<p class="section-header">O nas</p>
<p>O Firmie</p>
<p>Zespół</p>
<p class="green">Blog</p>
</div>
<div class="large-3 columns">
<p class="section-header">Pomoc</p>
<p>FAQ</p>
<p>Regulamin</p>
<p>Polityka prywatności</p>
</div>
<div class="large-3 columns">
<p class="section-header">Social Media</p>
<div class="social-media">
<img src="{{site.theme.link}}/static/img/social-media/facebook.png">
<img src="{{site.theme.link}}/static/img/social-media/twitter.png">
<img src="{{site.theme.link}}/static/img/social-media/instagram.png">
</div>
</div>
<div class="large-3 columns">
<p class="section-header">Kontrakt</p>
<div class="button green">Formularz kontaktowy</div>
</div>
</div>
<div class="row underline">
<div class="logo"></div><span>
<select>
<option value="Polski">Polski</option>
<option value="English">English</option>
</select>
</div>
</div>
I know it is wrong placed due to top:0 however I dont know how to make it stay right on the top border of footer.
I would be grateful for any help.
A similar example of yours, I think its usefull for your purpouse:
div {
border: solid 1px green;
margin-bottom: 20px;
}
footer {
position: relative;
height: 50px;
background-color: red;
text-align: center;
padding-top: 20px;
}
footer:before {
content: "";
position: absolute;
display: block;
top: -50%;
left: 0;
width: 100%;
height: 100%;
background: url("http://www.curtainshopsouthport.co.uk/scissors.png");
-moz-background-size: 90%;
background-size: 90%;
background-repeat: no-repeat;
background-position: left 50%;
}
<div>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ullam quis placeat architecto dolore recusandae nam amet, voluptate consequatur tenetur, quibusdam cupiditate culpa perferendis praesentium ab quasi voluptatum doloremque illum suscipit ea. Placeat
aperiam tempore maiores minus harum sint debitis beatae sit, eos voluptas est temporibus animi ullam praesentium voluptates molestiae dolore illo officiis blanditiis dolores. Qui labore asperiores quia dolore amet, culpa consectetur est quibusdam iusto
incidunt maxime aliquid sit eius explicabo aut, possimus corporis temporibus. Alias officia libero repellat veritatis, obcaecati repudiandae at voluptas, maxime doloremque facilis, sunt praesentium voluptatibus eaque provident natus, earum asperiores?
Possimus voluptatem, soluta deserunt.</div>
<footer>footer</footer>
As long as you don't have overflow issues, all you should need to do is replace top:0 with bottom:100%
footer{
position: relative;
&:before{
content: "";
position: absolute;
display: block;
bottom: 100%; /* change here */
left: 0;
width: 100%;
height: 100%;
padding-bottom: 50%;
background: url("img/line.svg");
-moz-background-size:90%;
background-size:90%;
background-repeat: no-repeat;
}
This question already has answers here:
Bootstrap full-width with 2 different backgrounds (and 2 columns)
(2 answers)
Closed 6 years ago.
I am having some trouble trying to create a layout like the image below. The left and right columns should take up 2/3 and 1/3 respectively of the main container max-width (which is centered using margin: auto;), but the remaining width of the page should be filled by the background image or the color of the column.
Is there some way to accomplish this with css?
It's a little tricky.
The problem is to avoid that the background image is cropped out of the body of the page, while a simple color fill is easier.
Try using :after and :before pseudo-elements with position:absolute; and putting there the background rules.
Then you need to force to fit all the page in all resolutions, so try these rules:
#left-column{
float:left;
width: 66.66%;
height:200px;
position:relative;
}
#left-column:before{
position:absolute;
/* for this example I used a free-copyright image from pixabay.com */
background:url(https://pixabay.com/static/uploads/photo/2016/05/01/00/57/barn-1364280_960_720.jpg) no-repeat;
background-size: 100% 100%;
top:0;
right:0;
width:100%;
padding-left:100%;
height:100%;
content:'';
display:block;
}
#right-column{
height:200px;
float:left;
width:33.33%;
position:relative;
}
#right-column:after{
position:absolute;
background:green;
top:0;
left:0;
width:10000px;
height:100%;
content:'';
display:block;
}
To show the content inside the columns give them a position:relative; z-index:1;.
Then you need to add to the body the following rule to avoid that backgrounds creates horizontal scroll-bar
body{
overflow-x:hidden;
}
To see it in a working example go here. .
If you prefer a more-accurate solution I think you must use javascript
You can emulate this with pseudo elements with large width:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
p {
margin-bottom: 16px;
}
.wrapper {
overflow-x: hidden;
min-height: 100vh;
}
.container {
border-left: 1px solid #ddd;
border-right: 1px solid #ddd;
max-width: 800px;
height: 700px;
margin: 0 auto;
}
.cols {
min-height: 300px;
display: flex;
}
.left {
background: linear-gradient(to right, #F9B80E, #E3342E);
flex: 0 0 66.6%;
position: relative;
}
.left:before {
content: '';
background: linear-gradient(to right, #FFED21, #F9B80E);
position: absolute;
right: 100%;
width: 1000px;
top: 0;
bottom: 0;
}
.right {
background: #E5E5E4;
position: relative;
padding: 20px;
}
.right:after {
content: '';
background: #E5E5E4;
position: absolute;
left: 100%;
width: 1000px;
top: 0;
bottom: 0;
}
<div class="wrapper">
<div class="container">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae, quam. Dolore unde repudiandae deleniti, explicabo voluptatum, consequatur soluta architecto cumque! Modi sit doloremque veniam dignissimos porro nulla, exercitationem illum possimus!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae, quam. Dolore unde repudiandae deleniti, explicabo voluptatum, consequatur soluta architecto cumque! Modi sit doloremque veniam dignissimos porro nulla, exercitationem illum possimus!</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quae, quam. Dolore unde repudiandae deleniti, explicabo voluptatum, consequatur soluta architecto cumque! Modi sit doloremque veniam dignissimos porro nulla, exercitationem illum possimus!</p>
<div class="cols">
<div class="left"></div>
<div class="right">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Fugiat esse, corporis, quis accusantium, adipisci sequi animi cupiditate distinctio blanditiis consequuntur illo molestias velit dolorem qui sit voluptas. Labore cupiditate, quis.</p>
</div>
</div>
</div>
</div>
I have a fixed side bar on the left and a right content area. Is there an alternative to calculating the content width other than calc()? I wanted a more browser safe method.
.left-sidebar {
width: 160px;
height: 100%;
border-right: 1px solid black;
position: fixed;
top: 72px;
}
.right-content {
position: absolute;
left: 160px;
top: 72px;
width: calc(100% - 160px);
overflow: hidden;
}
I have already done a similar example, which I would like to share. You need to use positioning for this case. This is a case of fixed-fluid:
+-------+-----------+
| FIXED | FLUUUUUID |
+-------+-----------+
Or
+-------+-----------+
| FIXED | FLUUUUUID |
| | FLUUUUUID |
+-------+-----------+
Fixed-Fluid Model. In my snippet, I have demonstrated two kinds of examples. In the first case, the fluid is less in size. And the next has too long content.
Snippet
.parent {position: relative; margin: 0 0 15px; border: 1px solid #999; padding: 5px; padding-left: 100px;}
.parent .fixed {position: absolute; left: 5px; width: 90px; background-color: #99f;}
.parent .fluid {background-color: #f99;}
<div class="parent">
<div class="fixed">Fixed</div>
<div class="fluid">Fluid</div>
</div>
<div class="parent">
<div class="fixed">Fixed</div>
<div class="fluid">Fluid Lorem ipsum dolor sit amet, consectetur adipisicing elit. Itaque animi placeat, expedita tempora explicabo facilis nulla fuga recusandae officia, maiores porro eaque, dolore et modi in sapiente accusamus id aut.</div>
</div>
For a better fixed fluid, I have done with the same kind for you:
.main-content {border: 1px solid #999; padding: 5px; position: relative; min-height: 200px; padding-left: 125px;}
.left-sidebar {position: absolute; left: 0; top: 0px; width: 120px; background-color: #eee; height: 100%;}
<div class="main-content">
<div class="left-sidebar"></div>
<div class="right-fluid">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum libero iure facere quam iste, nostrum laborum in, dolorum beatae optio rem explicabo voluptates qui quos eius accusamus! Accusamus blanditiis, et!
</div>
</div>
I am trying to vertically align to the middle at all times an open quote by a pseudo element. As you shrink the size it aligns, but by default it's above my quote. Is there a way I can have it vertically in the middle aligned at all times?
CSS
blockquote {
margin: 3em;
padding: 0 3em;
position: relative;
}
blockquote::before {
content: open-quote;
left: -40px;
}
blockquote::before, blockquote::after {
top: 50%;
color: #F1722E;
font-size: 124px;
position: absolute;
transform: translateY(-50%);
}
HTML
<blockquote>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellendus iure rem repudiandae incidunt corporis obcaecati voluptate officia. Facere laborum ipsam molestiae dolorum libero nesciunt ducimus aliquid voluptatibus. Ad praesentium fugiat.</blockquote>
http://jsfiddle.net/gfybkpc9/
You can do it by adjusting the margin top of the open quote. See this fiddle
I adjusted the CSS like so:
blockquote {
margin: 3em;
padding: 0 3em;
position: relative;
}
blockquote::before {
content:'"';
left: -40px;
}
blockquote::before, blockquote::after {
top: 50%;
color: #F1722E;
font-size: 124px;
position: absolute;
margin-top:-48px;
}
Essentially, the margin top would be half the height of the element, which would position the middle of the element at 50%, per the top property. Since it's a quote mark, we have to fudge the numbers a little.