Is it possible to utilize the Linear-gradient property for creating a vertical background color effect?

I'm currently attempting the following:

body {
    height:100%;
    background: -moz-linear-gradient(left, #DB2B39 50%, #2B303A 50%);
    background: -webkit-linear-gradient(left, #DB2B39 50%,#2B303A 50%);
    background: linear-gradient(to right, #DB2B39 50%,#2B303A 50%);
}

However, this code is only creating a horizontal split. It seems strange that you can't achieve a vertical split without stripes.

Is there something glaringly obvious that I'm missing?

Answer №1

When you set the angle to "to right", a horizontal gradient is created. To generate a vertical gradient, use to bottom or top instead.

body {
    height:100%;
    background: -moz-linear-gradient(top, #DB2B39 50%, #2B303A 50%);
    background: -webkit-linear-gradient(top, #DB2B39 50%,#2B303A 50%);
    background: linear-gradient(to bottom, #DB2B39 50%,#2B303A 50%);
}

For more information on values for linear-gradient, visit here.

Answer №2

To achieve the desired effect, ensure to include the value "fixed". Refer to the code snippet below for implementation.

body {
background: linear-gradient(to bottom,  rgba(219,43,57,1) 50%,rgba(43,48,58,1) 50%,rgba(10,8,9,1) 50%) fixed; 
}

http://codepen.io/adamfollett/pen/YWBmxR

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Content missing after centered banner

Seeking help! I need to figure out how to center text after a container. Whenever I try, it ends up either behind the banner picture or misaligned. I want both the banner and the text example to be centered, but placing the text in the right position has b ...

Carousel Image Alignment Issue on iPhone SE Portrait Mode: All Images Centered Except One

Check out this website: It functions perfectly on Desktop browsers at all scales and works on Mobile devices in Landscape mode. However, I noticed that when using Portrait mode on my iPhone SE, the first image in the carousel appears off center in Chrome ...

When CSS width:auto expands beyond its intended length

I'm experiencing an issue when I set the width to auto, the div expands to full length rather than adjusting to the width of the inner divs. Here is the HTML code: <div class="vidswraper"> <div> <div class="videoimage"> <img src ...

The "read more" button seems to be malfunctioning

I've been working on integrating a gallery of images into my posts. My goal is to display 4 images initially, followed by a "load more" button that, when clicked, will reveal another set of 4 images, and so on. I have already created the HTML, CSS, an ...

expanding the input and duplicating the outcomes

I'm attempting to clone and add values to results in my project. Here's the link to what I have so far: http://jsfiddle.net/QNP3r/175/ Currently, it is functioning adequately with a table element. However, I'd like to make it work with a di ...

Tips for integrating SASS from the Bulma package into an Angular application

I'm currently working on implementing Bulma into my project. The documentation suggests using NPM to obtain it. yarn add bulma Further in the documentation, there is an example provided with code snippets like the ones below. <link rel="styles ...

Div that scrolls independently without affecting the position of other elements

Visit this link for reference <div class="col-10 content" id="content"> <ul> <li>News</li> <li>News</li> <li>News</li> <li>News</li> < ...

What is the best way to make HTML adjust to SVG scaling?

After applying a scale transform to an SVG, I noticed that the surrounding HTML does not adjust its size accordingly. Here is the SVG in question: <div> <svg height="300" width="300" viewbox="0 0 300 300" transform="scale(1.55)" xmlns= ...

Center the div element and adjust its scale to perfectly fit the screen

I have been struggling to optimize my website for mobile devices by centralizing the content display. When I access it on a mobile device through , there is excessive space below the content, forcing me to pinch zoom in order to read properly. How can I el ...

Learn how to apply inline styles to multiple objects within a single element using React

In my project using React, I am attempting to apply styles only to a specific element within another element. Here is an example with an h1 tag: const Header = () => { const firstName = "Ashraf"; const lastName = "Fathi"; const date = new Date() ...

I am interested in using an image upload box that includes a hidden input field. However, I have encountered issues with the functionality when the input field is hidden. Does anyone have any suggestions on how

I have limited experience and need some assistance with resolving this particular issue. I am looking to create an image upload box that works when clicked on the input field. Thank you in advance. function readURL(input) { if (input.files && ...

How can I extract information from Firebase and set it in the this.props of a React component?

Hey there, I'm having some trouble with my Firebase setup. I need to transfer data from snapshot.val() into this.props.device, but when I try to do so within the this.firebaseRef.on() function, 'this' is showing up as 'null'. Any s ...

Ways to trigger the display of an image upon hovering over a button without using inheritance

<div class="a"> <img class="img_c" id="img_id" src="~~"> <div class="b"> <div class="c"> <ul class="d" id="e"> <li ~~~ > </ul> </div> </div> </div> Is there a way to display the ...

Ways to verify if options have been chosen or not?

if(isset($_POST["marketing"])){ foreach($_POST as $key => $value){ if(strlen($value)<1) continue; echo "<option value='".$value."' selected >".$value."</option>"; } I have a PHP script that dynamically cre ...

Is it possible to transform div containers into unique shapes?

I'm working on a design where I want to have two divs that resemble teeth, one on the top half of the page and the other on the bottom half. The concept is to make these mouth piece divs open and close as you scroll with the mouse, revealing the conte ...

Credit for the Position swipejs

After integrating a swipeJS photo slideshow into my jQuery mobile application, I encountered an issue. I am trying to create points for counting the pictures similar to what is seen on this page: Although I have added the necessary HTML and CSS code to my ...

Unable to transfer a value from a CGI script back to an HTML form

When working with an HTML form that has a date field named cdt, I encountered the need to retain the date value when submitting data to an Oracle table through a CGI script. To achieve this, instead of using Javascript code like history.go(-1), I aimed to ...

What is the process to enable mandatory validation after a change in input in Angular 4?

Currently, I am working on a project using Angular 4. One of the tasks I need to achieve is validation. <input [(ngModel)]="someModel" required placeholder="some placeholder"/> The validation triggers immediately, but I want it to only trigger aft ...

What is the correct way to utilize href in CSS content property?

Below is the content of a box I have: https://i.sstatic.net/QmG5i.png When the above box is hovered over, it flips to this: https://i.sstatic.net/QsS9t.png This block's HTML code is as follows: <div class='tiles'> <div class= ...

What are the steps to create a horizontal submenu in WordPress?

Is there a way to change the default vertical sub menu of my main menu to horizontal? The CSS for the sub menu in stylesheet.css is as follows: .main-nav>ul>li .sub-menu> li { padding:0 20px; } .main-nav>ul>li .sub-menu> li:first-ch ...