Alter the text color once the halfway point is reached at an angle of 175 degrees

I want the text color to turn white when the background color changes to blue after reaching 50% height with a 175 degree angle. Check out this Fiddle

.bg {
      background: linear-gradient(175deg, #e2e2e2 50%, #435289 50%);
      color:#000;
}
<div class="bg">
<h1>
 Hiii, My Name is John, I love Stackoverflow. I really don't know, how to do this, Can someone help me? If Background = Blue, Text Color = White
</h1>
  
</div>


</div>

Answer №1

Check out this new solution:

To create an interesting text effect, try setting the background of the h1 element using linear-gradient with your desired colors for the text. Then, make the text color transparent and apply background-clip: text to color the text accordingly. Make sure to check the compatibility across browsers.

.bg {
  background: linear-gradient(175deg, #e2e2e2 50%, #435289 50%);
  color: #000;
}

h1 {
  color: transparent;
  background: linear-gradient(175deg, #435289 50%, white 50%);
  -webkit-background-clip: text;
  background-clip: text;
}
<div class="bg">
  <h1>
    Hiii, My Name is John, I love Stackoverflow. I really don't know, how to do this, Can someone help me? If Background = Blue, Text Color = White
  </h1>

</div>


</div>

Here's the original suggestion:

If you're looking for contrast instead of exact colors, consider utilizing mix-blend-mode to dynamically adjust the text color based on the background:

.bg {
  background: linear-gradient(175deg, #e2e2e2 50%, #435289 50%);
  color: #000;
}

h1 {
  color: #fff;
  mix-blend-mode: difference;
}
<div class="bg">
  <h1>
    Hiii, My Name is John, I love Stackoverflow. I really don't know, how to do this, Can someone help me? If Background = Blue, Text Color = White
  </h1>

</div>


</div>

Answer №2

you have the option to implement that particular color scheme. check it out at https://jsfiddle.net/h7jhcbm0/2/

.bg {
  background: linear-gradient(175deg, #e2e2e2 50%, #435289 50%);
  color: #000;
}

h3 {
  color: #fff
}

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

Utilizing multiple div IDs within the same script functionality

I have multiple dropdown menus on a webpage, and whenever an onchange event happens with any of these menus, I want to utilize the same block of code rather than creating individual scripts for each menu's id. This approach is preferred as the page ma ...

The module in Node.js is unable to be loaded

Dealing with a common problem here. Despite trying to reinstall npm, deleting node_modules files and package-lock.json, the issue persists. The console output is as follows: node:internal/modules/cjs/loader:1080 throw err; ^ Error: Cannot find module &apo ...

How can I send a jQuery ajax request with multiple custom headers?

I am facing an issue with my basic ajax request as I am trying to include a custom header using the following code: _auth=1,[my_apikey], Interestingly, when I make the same request using Postman, I receive a valid JSON response. However, when I attempt t ...

Utilizing JavaScript to Trigger a Function from Code Behind

Having trouble calling a function through javascript and receiving an error message "CS0103: The name 'bidindex' does not exist in the current context". Can anyone provide assistance? Thank you! JavaScript code snippet: <script> funct ...

Triggering a server-side event handler in ASP.NET using client-side JavaScript

I need help with implementing a countdown timer in JavaScript. When the timer reaches 0 seconds, I would like the page to trigger the button1_click event handler. Here's the scenario: I am working on a quiz engine where the quiz responses need to be ...

Creating a tree structure from an array in JavaScript, including the parent id enclosed in brackets

Before dismissing this question as a duplicate, please listen to me. I am working with a json response in reactjs that looks like the following organisationUnits: [ { name: "0.Mzondo", id: "nW4j6JDVFGn", parent: { ...

What are the drawbacks of using JavaScript to load a series of images?

Currently, I am facing an issue with the loading speed of a sequence of images on my website. The javascript code I have implemented to cycle through 50 images works perfectly fine locally but becomes slow and buggy when the site is live. Despite the image ...

The background-color and text color properties in CSS are failing to apply

Struggling with my HTML homework, following the book instructions but still getting errors. Can anyone here help me figure out what's wrong? questions: 1: Add a blank line after the CSS reset style rule, add a comment with the text, Style rule for bo ...

Exciting feature: Changing text color dynamically with Sass

Is it possible to create a mixin that sets text color based on the background? It seems straightforward with one color, but how about when there are two colors or changing the color of half of the text? Try changing the text with a blue background.. http ...

Steps for storing div content (image) on server

Currently in the process of developing a web application that allows users to crop images. The goal is for users to have the ability to email the URL so others can view the cropped image, ensuring that the URL remains active indefinitely by storing every c ...

Bony Scaffold - halting the motion of specific components

Currently, I am utilizing skeleton to create a fluid layout, which is functioning effectively for the most part. However, I have encountered an issue specifically with the 2 column layout on Magento at this URL: In this setup, the navigation on the left s ...

Understanding the variations in behavior of the history.go(-1) method across various browsers

Is history.go(-1); consistent across all browsers? I've noticed different behaviors on various browsers. In my code, I have a line similar to javascript:history.go(-1); On the first page, there are three checkboxes. Users can only select two of them ...

What is the method for providing external parameters to a JOI extension?

Perhaps JOI may not be the ideal tool for this particular task, but I am interested in utilizing it if feasible. Essentially, I have a scenario where a user is sending a request to an API to store specific metric data. Certain metrics are restricted based ...

What is the best way to adjust my column position in order to make the links clickable?

Looking for help with a mobile version website menu bar design. The issue is that the central "+" button is covering the two icons on either side, making them unclickable. Is there a solution to rearrange this layout? Here is the current design: https:// ...

Guide on converting a JavaScript object into an array consisting of key and value pairs

I have information that appears as follows: [{"letter": "a", "word" : "apple"}, {"letter": "b", "word":"ball"}, {"letter": "a", "word":"alpha"}, {"letter": "c", "word":"cat"}] My goal is to convert it into: {"a":["apple", "alpha"], "b": ["ball"], "c":[" ...

Struggling to develop an age calculator tool that allows users to adjust the value using an up and down arrow function

https://i.sstatic.net/8Qjuf.png I'm currently working on a project that involves creating a tool to display a label with up and down arrows for adjusting the "Age" value. However, I've noticed that whenever I refresh the page, the functionality ...

Is the existence of the file also verified by JavaScript's realpathSync() function?

I want to utilize node.js FileSystem realpathSync() to find the actual path of a file. Does realpathSync() also verify if the file exists? Would this code be sufficient: try { res = fs.realpathSync(path); } catch (err) { ...

Organizing a set of div elements based on their ID attributes

I am faced with the challenge of sorting a list of divs based on their ID values, which are in the format "indexNumber123". Instead of arranging them alphabetically, I want to sort them numerically as "indexNumber1", "indexNumber2", "indexNumber3" before d ...

utilizing JSON data in a React application

I am working on a React project that involves a parent to grandchild hierarchy. In my code, I am passing values as JSON Objects. There are two input boxes where users can enter values and a button that stores and displays the values when clicked. Below is ...

Verification of Form Submission

Looking for some help with web design, specifically regarding cache issues. I have a website where form data is submitted from form.php to buy-form.php. I'm trying to set up a cache error in Google Chrome so that when buy-form.php is accessed directl ...