473,765 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can you use if/else conditions in CSS?

MusoFreak200
96 New Member
I would like to use conditions in my CSS.

The reason is because for the life of me i cannot work out how to get linear gradients to display in IE browsers so i want to have browser to display an image instead if the browser is an IE browser and to display the linear gradient code if it is any other browser.

so far my code looks like this:

Expand|Select|Wrap|Line Numbers
  1. #rightsidegradientbar 
  2. {
  3.     width:50px;
  4. background-image: -webkit-gradient(
  5.     linear,
  6.     right bottom,
  7.     left bottom,
  8.     color-stop(0.1, #FFFFFF),
  9.     color-stop(0.78, #00CCCC),
  10.     color-stop(1, #00CCCC)
  11. );
  12. background-image: -moz-linear-gradient(
  13.     right center,
  14.     #FFFFFF 10%,
  15.     #00CCCC 78%,
  16.     #00CCCC 100%
  17. );
  18. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#00CCCC');}
  19.  
if you would like to check out my most recent question it is linked here:
http://bytes.com/topic/html-css/answ...ts#post3665036

thank you in advance for any help or suggestions that you may be able to pose.
Jul 2 '11 #1
2 13739
Sudaraka
55 New Member
Programming concepts like decision making and iteration (if/else and loops) are not available in CSS, as CSS is not a programing language.

However, in IE (only) you can use HTML conditional comments in include different style sheets (.css files or <style> tags) so that different CSS can be applied to the document in different conditions (i.e. different IE versions)

http://www.javascriptkit.com/howto/cc2.shtml
Jul 3 '11 #2
MusoFreak200
96 New Member
thank you heaps sudaraka but i have solved my own gradient problem..

but i am very interested in your link and post so i will mark it as answer
Jul 3 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

33
3859
by: Diez B. Roggisch | last post by:
Hi, today I rummaged through the language spec to see whats in the for ... else: for me. I was sort of disappointed to learn that the else clauses simply gets executed after the loop-body - regardless of the loop beeing entered or not. So where is an actual use case for that feature? I imagined that the else-clause would only be executed if the loop body
6
2510
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a if statement by itself works just fine. Below is an example: if x >=0: DO SOMETHING Would it be better, or perhaps more complete, written like this:
27
3079
by: Ron Adam | last post by:
There seems to be a fair amount of discussion concerning flow control enhancements lately. with, do and dowhile, case, etc... So here's my flow control suggestion. ;-) It occurred to me (a few weeks ago while trying to find the best way to form a if-elif-else block, that on a very general level, an 'also' statement might be useful. So I was wondering what others would think of it.
24
1824
by: gupta.keshav | last post by:
HI, Is there any situation which can be handled by ternary operator but not with if else blocks? Thanks Keshav
24
8630
by: Kunal | last post by:
Hello, I need help in removing if ..else conditions inside for loops. I have used the following method but I am not sure whether it has actually helped. Below is an example to illustrate what I have used. Original code : c= 0 ; for (i=0; i<999; i++)
14
2349
by: Ørjan Langbakk | last post by:
I have a form where the user has the possibility to enclose his name. email, address and phonenumber. I want to be able to check if some of the fields are filled - at least one. This is so that we have some way to contact the customer. Today I check for the existence of an email-address, and a validation code - what I need is a way to check, eg. whether email _or_ phone is entered, and if none is entered, display an errorpage.
3
1533
by: divya | last post by:
Hiii, Please read the following piece of code:- function SendToWebServer1(sendto) //sendto string contains a URL { if (document.form1.txtbookedby.value == "") { alert('your name field cannot be empty');
1
1260
by: KRN000 | last post by:
hello every one i'm developing a web site using asp.net , with VB as the programming language. i want to ask: how can I implement "if else" conditions on the execution of a sql query? For example,write in the handler of a button :" IF radiobutton1 is selected THEN EXECUTE sqldatasource1 (or procedure1 ) ELSE EXECUTE sqldatasource2 ( or procedure2)". So I want execution of sql query to be appended with "IF ELSE" conditions. thank you
23
2780
by: bearophileHUGS | last post by:
So far in Python I've almost hated the 'else' of the 'for' loops: - I have problems to remember its meaning; - It gives me little problems when I later want to translate Python code to other languages (and you always have to translate long-lived code). - I have used it only once, so far. So so far I'd liked to see it removed from Python 3.0. But then this article:
10
1658
by: arcticool | last post by:
I was just surprised to find that "Else if" is not required in the code bit below. Apparently "If" and "Else if" are used interchangeably. Please correct me if I'm wrong, but it appears "Else" is just a stylistic choice. for (int i = 1; i <= 100; i++) { if (i == 3) continue; if (i == 5) break;
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8832
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7379
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.