si

Gopi Thotakura to become 1st Indian space tourist to fly on Jeff Bezos's Blue Origin’s NS-25 mission

Gopi Thotakura was selected as one of the six crew members for the mission




si

Elon Musk to meet Indian space tech founders during Delhi visit

SpaceX founder and Tesla CEO Elon Musk is likely to meet India’s top space technology entrepreneurs in Delhi later this week




si

Krishna Ella is new president of Indian Vaccine Manufacturers Association

“Vaccines are the vital pillar of global health, and the IVMA mission is to ensure that every individual, regardless of where they live, has access to life-saving immuniszations” - Krishna Ella, Co-Founder, Executive Chairman of Bharat Biotech




si

Covishield: AZ cites regulators’ view that benefits outweigh risk of ‘extremely rare potential side effects’

AstraZeneca’s Covid-19 vaccine faces UK class action suit; Serum Institute markets it in India as Covishield




si

India flight tests missile-assisted torpedo release system

The system was launched around 8.30 am from the ground mobile launcher.




si

Why is blood red? A simple explanation for kids

Understanding the colour of blood helps us appreciate the complex yet fascinating workings of our bodies




si

IIT Madras partners with SilTerra Malaysia for silicon photonic processor chips

These chips will be utilised for quantum computing and high-speed secured communication systems




si

NASA will soon train Indian astronauts for joint mission to International Space Station: US Envoy Eric Garcetti

NASA to provide advanced training to Indian astronauts for joint mission to International Space Station, US envoy Eric Garcetti says




si

Earthquake 2,500 years ago possibly altered Ganga River’s course, study says

The study, published in Nature Communications, marks the first confirmed instance of an earthquake driving avulsion in deltas, particularly for a river as immense as the Ganga. 




si

Despite funding crunch, India’s deeptech start-ups has grown 2x since 2022

India ranks 6th amongst the top nine deeptech ecosystems globally




si

Non-toxic ionic liquids for silk processing 

A team at IASST Guwahati has identified 4 different Ionic Liquids that can be effective in extracting silk proteins from raw fibres 




si

Saturn’s moon Titan: Cassini radar reveals hydrocarbon sea details

Recent analyses of Cassini’s radar data reveal detailed characteristics of Titan’s liquid hydrocarbon seas, primarily composed of methane and ethane. 




si

HYLENR demonstrates cold fusion technology to generate clean energy  

The technology has received a patent from the government




si

Indian astrophysicist Prahlad Chandra Agrawal honoured with COSPAR Harrie Massey Award 2024

Prahlad Chandra Agrawal is the first Indian recipient of this award, which recognizes outstanding contributions to the development of space research, particularly those in a leadership role.




si

Budget 2024: National Quantum Mission tees off with ₹427-cr budgetary support

The Mission aims to seed, nurture and scale up scientific and industrial R&D and create a vibrant and innovative ecosystem in quantum technology




si

Bharat Small Reactors being readied, modification of 220 MW reactors under way, says Atomic Energy Commission’s Grover

Modification minimal, change incremental, says RB Grover




si

India to sign High Seas Treaty in September, joining global effort to protect ocean biodiversity

India’s participation will enable it to contribute to global ocean governance, access biodiversity funds, and play a role in establishing marine protected areas and sharing marine genetic resources.




si

SpaceX delays launch of first-ever private spacewalk mission

The signature moment of the mission was to be a spacewalk by billionaire Jared Isaacman and SpaceX engineer Sarah Gillis




si

Helium’s role in space missions: Challenges and alternatives

This story discusses the reasons why helium is used in spacecraft and rockets, how it is prone to leaks, and the potential alternatives being explored




si

Cabinet clears ₹32,000 crore proposals for key space missions

Funds cover Chandrayaan-4, Venus Orbiter, space station, and next-gen launch vehicle




si

Chandrayaan-3 landed on possibly oldest craters of Moon: Scientists

A crater is formed when an asteroid crashes into the surface of a larger body like a planet or a Moon.




si

AI pioneers John Hopfield and Geoffrey Hinton awarded Nobel Prize in Physics

Hinton, often referred to as the “Godfather of artificial intelligence,” alongside Hopfield, an American scientist working at Princeton, have utilised principles from physics to create algorithms and neural networks that underpin today’s AI technologies




si

ShakthiSAT mission to train 12,000 girls from 108 nations; aims satellite launch under Chandrayaan-4

Aerospace startup Space Kidz India to select one student from each of the 108 participating countries who will travel to India for hands-on training in building payloads, spacecraft prototypes




si

Europa Clipper: NASA’s billion-dollar mission to explore the potential for life on Jupiter’s Moon

Embarking on a 1.8 million-mile journey from Kennedy Space Centre, the spacecraft is set to reach Jupiter in 5 1/2 years, utilising gravity assists from Mars and Earth




si

What are solid-fuel missiles, and why is North Korea developing them?

Solid-fuel missiles, easier to store and faster to launch than liquid-fuel counterparts, represent a strategic leap for Pyongyang’s defence capabilities 




si

Day Trading Guide for October 30, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

Day trading guide for October 31, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

IndusInd, Bandhan, RBL, IDFC First, Kotak, Ujjivan et al. - Dissecting the MFI worry 

Many private banks have been hit by the turbulent MFI segment. Read on to know what has caused this distress and how investors should play this space safely




si

Tax Query: Tax relief for arrear pension

Under Section 89(1) of the Income Tax Act, 1961, you may claim tax relief on arrear pension received from previous years




si

Swiggy IPO analysis: You can take a shot, but maybe not a big swig

The ₹11,327-crore IPO of Swiggy will value the company at a market cap of ₹87,000 crore and enterprise value (EV) of ₹78,000 crore




si

Gold, silver shine but correction possible

Underlying forces spurring demand for the metals include geopolitical tensions and uncertainties about the outcome of the U.S. Presidential polls




si

Day trading guide for November 5, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

Day trading guide for November 6, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

Day trading guide for November 7, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

Stock to buy today: PNB Housing Finance (₹999.2)

The price action over the past couple of weeks indicates good buying interest




si

Day trading guide for November 8, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

Coming soon, a new asset class to consider

India’s securities regulator is looking to open up a fresh vehicle for investments for people in the mass affluent segment that will be different from existing mutual fund alternatives




si

Nifty Prediction Today – November 11, 2024: Resistance ahead. Go short on a rise

Nifty 50 November Futures contract can fall to 23,900




si

Day trading guide for November 12, 2024: Intraday supports, resistances for Nifty50 stocks

Here are the intraday supports and resistances for widely traded stocks such as Reliance Industries, ITC, ONGC, Infosys, HDFC Bank, TCS, and SBI



  • Day trading guide

si

Two options for using custom properties

Recently I interviewed Stefan Judis for my upcoming book. We discussed CSS custom properties, and something interesting happened.

We had a period of a few minutes where we were talking past one another, because, as it turns out, we have completely opposite ideas about the use of CSS custom properties. I had never considered his approach, and I found it interesting enough to write this quick post.

Option 1

Take several site components, each with their own link and hover/focus colours. We want to use custom properties for those colours. Exactly how do we do that?

Before my discussion with Stefan that wasn’t even a question for me. I would do this:

.component1 {
	--linkcolor: red;
	--hovercolor: blue;
}

.component2 {
	--linkcolor: purple;
	--hovercolor: cyan;
}

a {
	color: var(--linkcolor);
}

a:hover,a:focus {
	color: var(--hovercolor)
}

I set the normal and hover/focus colour as a custom property, and leave the definition of those properties to the component the link appears in. The first and second component each define different colours, which are deployed in the correct syntax. Everything works and all’s well with the world.

As far as I can see now this is the default way of using CSS custom properties. I wasn’t even aware that another possibility existed.

Option 2

Stefan surprised me by doing almost the complete opposite. He uses only a single variable and changes its value where necessary:

.component1 {
	--componentcolor: red;
}

.component1 :is(a:hover,a:focus) {
	--componentcolor: blue;
}
	
.component2 {
	--componentcolor: purple;
}

.component2 :is(a:hover,a:focus) {
	--componentcolor: cyan;
}
	
a {
	color: var(--componentcolor)		
}

At first I was confused. Why would you do this? What’s the added value of the custom property? Couldn’t you just have entered the colour values in the component styles without using custom properties at all?

Well, yes, you could. But that’s not Stefan’s point.

The point

In practice, component definitions have way more styles than just colours. There’s a bunch of box-model properties, maybe a display, and possibly text styling instructions. In any case, a lot of lines of CSS.

If you use custom properties only for those CSS properties that will change you give future CSS developers a much better and quicker insight in how your component works. If the definition uses a custom property that means the property may change in some circumstances. If it uses a fixed definition you know it’s a constant.

Suppose you encounter this component definition in a codebase you just inherited:

.component {
	--color: red;
	--background: blue
	--layout: flex;
	--padding: 1em;
	--borderWidth: 0.3em;
	display: var(--layout);
	color: var(--color);
	background: var(--background);
	padding: var(--padding);
	border: var(--borderWidth) solid black;
	margin: 10px;
	border-radius: 2em;
	grid-template-columns: repeat(3,1fr);
	flex-wrap: wrap;
}

Now you essentially found a definition file. Not only do you see the component’s default styles, you also see what might change and what will not. For instance, because the margin and border-radius are hard-coded you know they are never changed. In the case of the border, only the width changes, not the style or the colour. Most other properties can change.

The use of display: var(--layout) is particularly revealing. Apparently something somewhere changes the component’s layout from grid to flexbox. Also, if it’s a grid it has three equal columns, while if it’s a flexbox it allows wrapping. This suggests that the flexbox layout is used on narrower screens, switching to a grid layout on wider screens.

Where does the flexbox change to a grid? As a newbie to this codebase you don’t know, but you can simply search for --layout: grid and you’ll find it, probably neatly tucked away in a media query somewhere. Maybe there is a basic layout as well, which uses neither flexbox nor grid? Search for --layout: block and you’ll know.

Thus, this way of using custom properties is excellently suited for making readable code bases that you can turn over to other CSS developers. They immediately know what changes and what doesn’t.

Teaching aid?

There’s another potential benefit as well: this way of using custom properties, which are essentially variables, aligns much more with JavaScript’s use of variables. You set an important variable at the start of your code, and change it later on if necessary. This is what you do in JavaScript all the time.

Thus this option may be better suited to teaching CSS to JavaScripters, which remains one of my preoccupations due to the upcoming book.

Picking an option

Which option should you pick? That’s partly a matter of personal preference. Since the second option is still fairly new to me, and I rarely work on large projects, I am still feeling my way around it. Right at this moment I prefer the first way because I’m used to it. But that might change, given some extra time.

Still, I think Stefan is on to something. I think that his option is very useful in large codebases that can be inherited by other developers. I think it deserves careful consideration.



  • CSS for JavaScripters

si

position: sticky, draft 1

I’m writing the position: sticky part of my book, and since I never worked with sticky before I’m not totally sure if what I’m saying is correct.

This is made worse by the fact that there are no very clear tutorials on sticky. That’s partly because it works pretty intuitively in most cases, and partly because the details can be complicated.

So here’s my draft 1 of position: sticky. There will be something wrong with it; please correct me where needed.

The inset properties are top, right, bottom and left. (I already introduced this terminology earlier in the chapter.)

Introduction

position: sticky is a mix of relative and fixed. A sticky box takes its normal position in the flow, as if it had position: relative, but if that position scrolls out of view the sticky box remains in a position defined by its inset properties, as if it has position: fixed. A sticky box never escapes its container, though. If the container start or end scrolls past the sticky box abandons its fixed position and sticks to the top or the bottom of its container.

It is typically used to make sure that headers remain in view no matter how the user scrolls. It is also useful for tables on narrow screens: you can keep headers or the leftmost table cells in view while the user scrolls.

Scroll box and container

A sticky box needs a scroll box: a box that is able to scroll. By default this is the browser window — or, more correctly, the layout viewport — but you can define another scroll box by setting overflow on the desired element. The sticky box takes the first ancestor that could scroll as its scroll box and calculates all its coordinates relative to it.

A sticky box needs at least one inset property. These properties contain vital instructions, and if the sticky box doesn’t receive them it doesn’t know what to do.

A sticky box may also have a container: a regular HTML element that contains the sticky box. The sticky box will never be positioned outside this container, which thus serves as a constraint.

The first example shows this set-up. The sticky <h2> is in a perfectly normal <div>, its container, and that container is in a <section> that is the scroll box because it has overflow: auto. The sticky box has an inset property to provide instructions. The relevant styles are:

section.scroll-container {
	border: 1px solid black;
	width: 300px;
	height: 300px;
	overflow: auto;
	padding: 1em;
}

div.container {
	border: 1px solid black;
	padding: 1em;
}

section.scroll-container h2 {
	position: sticky;
	top: 0;
}

The rules

Sticky header

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Now let’s see exactly what’s going on.

A sticky box never escapes its containing box. If it cannot obey the rules that follow without escaping from its container, it instead remains at the edge. Scroll down until the container disappears to see this in action.

A sticky box starts in its natural position in the flow, as if it has position: relative. It thus participates in the default flow: if it becomes higher it pushes the paragraphs below it downwards, just like any other regular HTML element. Also, the space it takes in the normal flow is kept open, even if it is currently in fixed position. Scroll down a little bit to see this in action: an empty space is kept open for the header.

A sticky box compares two positions: its natural position in the flow and its fixed position according to its inset properties. It does so in the coordinate frame of its scroll box. That is, any given coordinate such as top: 20px, as well as its default coordinates, is resolved against the content box of the scroll box. (In other words, the scroll box’s padding also constrains the sticky box; it will never move up into that padding.)

A sticky box with top takes the higher value of its top and its natural position in the flow, and positions its top border at that value. Scroll down slowly to see this in action: the sticky box starts at its natural position (let’s call it 20px), which is higher than its defined top (0). Thus it rests at its position in the natural flow. Scrolling up a few pixels doesn’t change this, but once its natural position becomes less than 0, the sticky box switches to a fixed layout and stays at that position.

The sticky box has bottom: 0

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Sticky header

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

It does the same for bottom, but remember that a bottom is calculated relative to the scroll box’s bottom, and not its top. Thus, a larger bottom coordinate means the box is positioned more to the top. Now the sticky box compares its default bottom with the defined bottom and uses the higher value to position its bottom border, just as before.

With left, it uses the higher value of its natural position and to position its left border; with right, it does the same for its right border, bearing in mind once more that a higher right value positions the box more to the left.

If any of these steps would position the sticky box outside its containing box it takes the position that just barely keeps it within its containing box.

Details

Sticky header

Very, very long line of content to stretch up the container quite a bit

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

The four inset properties act independently of one another. For instance the following box will calculate the position of its top and left edge independently. They can be relative or fixed, depending on how the user scrolls.

p.testbox {
	position: sticky;
	top: 0;
	left: 0;
}

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

The sticky box has top: 0; bottom: 0

Regular content

Regular content

Regular content

Regular content

Sticky header

Regular content

Regular content

Regular content

Regular content

Regular content

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Setting both a top and a bottom, or both a left and a right, gives the sticky box a bandwidth to move in. It will always attempt to obey all the rules described above. So the following box will vary between 0 from the top of the screen to 0 from the bottom, taking its default position in the flow between these two positions.

p.testbox {
	position: sticky;
	top: 0;
	bottom: 0;
}

No container

Regular content

Regular content

Sticky header

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

So far we put the sticky box in a container separate from the scroll box. But that’s not necessary. You can also make the scroll box itself the container if you wish. The sticky element is still positioned with respect to the scroll box (which is now also its container) and everything works fine.

Several containers

Sticky header

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Content outside container

Content outside container

Content outside outer container

Content outside outer container

Or the sticky item can be several containers removed from its scroll box. That’s fine as well; the positions are still calculated relative to the scroll box, and the sticky box will never leave its innermost container.

Changing the scroll box

Sticky header

The container has overflow: auto.

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Content outside container

Content outside container

Content outside container

One feature that catches many people (including me) unaware is giving the container an overflow: auto or hidden. All of a sudden it seems the sticky header doesn’t work any more.

What’s going on here? An overflow value of auto, hidden, or scroll makes an element into a scroll box. So now the sticky box’s scroll box is no longer the outer element, but the inner one, since that is now the closest ancestor that is able to scroll.

The sticky box appears to be static, but it isn’t. The crux here is that the scroll box could scroll, thanks to its overflow value, but doesn’t actually do so because we didn’t give it a height, and therefore it stretches up to accomodate all of its contents.

Thus we have a non-scrolling scroll box, and that is the root cause of our problems.

As before, the sticky box calculates its position by comparing its natural position relative to its scroll box with the one given by its inset properties. Point is: the sticky box doesn’t scroll relative to its scroll box, so its position always remains the same. Where in earlier examples the position of the sticky element relative to the scroll box changed when we scrolled, it no longer does so, because the scroll box doesn’t scroll. Thus there is no reason for it to switch to fixed positioning, and it stays where it is relative to its scroll box.

The fact that the scroll box itself scrolls upward is irrelevant; this doesn’t influence the sticky box in the slightest.

Sticky header

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Regular content

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

Content outside container

One solution is to give the new scroll box a height that is too little for its contents. Now the scroll box generates a scrollbar and becomes a scrolling scroll box. When we scroll it the position of the sticky box relative to its scroll box changes once more, and it switches from fixed to relative or vice versa as required.

Minor items

Finally a few minor items:

  • It is no longer necessary to use position: -webkit-sticky. All modern browsers support regular position: sticky. (But if you need to cater to a few older browsers, retaining the double syntax doesn’t hurt.)
  • Chrome (Mac) does weird things to the borders of the sticky items in these examples. I don’t know what’s going on and am not going to investigate.



  • CSS for JavaScripters

si

New business wanted

Last week Krijn and I decided to cancel performance.now() 2021. Although it was the right decision it leaves me in financially fairly dire straits. So I’m looking for new jobs and/or donations.

Even though the Corona trends in NL look good, and we could probably have brought 350 people together in November, we cannot be certain: there might be a new flare-up. More serious is the fact that it’s very hard to figure out how to apply the Corona checks Dutch government requires, especially for non-EU citizens. We couldn’t figure out how UK and US people should be tested, and for us that was the straw that broke the camel’s back. Cancelling the conference relieved us of a lot of stress.

Still, it also relieved me of a lot of money. This is the fourth conference in a row we cannot run, and I have burned through all my reserves. That’s why I thought I’d ask for help.

So ...

Has QuirksMode.org ever saved you a lot of time on a project? Did it advance your career? If so, now would be a great time to make a donation to show your appreciation.

I am trying my hand at CSS coaching. Though I had only few clients so far I found that I like it and would like to do it more. As an added bonus, because I’m still writing my CSS for JavaScripters book I currently have most of the CSS layout modules in my head and can explain them straight away — even stacking contexts.

Or if there’s any job you know of that requires a technical documentation writer with a solid knowledge of web technologies and the browser market, drop me a line. I’m interested.

Anyway, thanks for listening.




si

Redefining inclusivity

Blind Bake and The Echoes are unique cafes that provide employment to specially abled people 




si

IISc study reveals that picolinic acid can block viruses causing SARS-CoV-2 and influenza A

The study describes the compound’s remarkable ability to disrupt the entry of enveloped viruses into the host’s cell and prevent infection




si

Ruhani Sharma: I play a close-to-reality cop in ‘HER’; there is no scope for ‘Singham’ style of histrionics

Ruhani Sharma talks about headlining the Telugu cop drama franchise ‘HER’, says she never imagined herself as a sharpshooter 




si

After a dull six months, Hostel Hudugaru Bekagiddare brings cheer to Kannada film industry

 After a memorable 2022, the industry suffered a slump in the first half of this year with only Daredevil Musthafa providing a consolation




si

Bengaluru-Mysuru expressway was opened in haste, says CM Siddaramaiah




si

A silver lining for the jewellery makers

Delhi school girl Rhea Bakshi’s documentary on the plight of silver jewellery artisans in India bags honours at the New York International Film Awards NYIFA finalist Rhea Bakshi talks about her documentary and the struggle for an inclusive economy.      




si

Parental behaviour closely associated with adolescents’ excessive Internet use, finds NIMHANS study

The study showed that decreased care and increased control from the mother, high autonomy from father and increased rejection from both parents as risk factors associated with adolescent internet excessive use




si

Chiranjeevi to team up with director Vassishta for his next

Chiranjeevi’s 156th and 157th films announced to coincide with the Telugu superstar’s birthday; one of the films will be directed by Vassishta