How to set an element to show on medium screen and below in Tailwind? - responsive-design

I have a div with a class of hidden md:block housing this element from heroicon:
<MenuIcon class="ml-1 mr-2 h-5 w-5 text-gray-500"/>.
Currently, the div element only show when the screen size is at md, but I want to show at md and below, how exactly do I do that?

Tailwind breakpoints are mobile first, so they go UP. At first everything is visible.
You just need to hide elem. from some size and up:
sm -> md -> lg -> xl -> 2xl
class="lg:hidden" will hide element from lg and above - lg, xl, 2xl
For more info about the topic look at: Responsive design in Tailwind

I believe you are doing it in reverse.
Basically =>
https://tailwindcss.com/docs/responsive-design
Where this approach surprises people most often is that to style
something for mobile, you need to use the unprefixed version of a
utility, not the sm: prefixed version. Don’t think of sm: as meaning
“on small screens”, think of it as “at the small breakpoint“.
So you would have to do class="block lg:hidden" in your classes for it to work as you are describing :)

Related

Inner section in Elementor issue for phone screen

enter image description here
enter image description here
Hello, I have an issue. I did add 2 inner sections in Elementor which contain 3 columns. For desktop, it looks great but for the phone, I cannot make it into 2 columns. Anybody can advise me, please?
You'll have a hard time doing this if your content is split between different inner sections.
Here's how you could do it with a little CSS.
(1) Create a new section with just one column, and add all your content to this one column. For illustration, I'm using paragraphs but the same principle will apply for other content.
(2)Go to section settings > advanced > advanced, and give this section a class of 'item-wrap'
(3) Go to section settings > advanced > custom CSS and add the following
/* set default widget width to 50% */
.item-wrap .elementor-widget-wrap>.elementor-element {
width: 50%;
}
/* set widget width to 33.33% on tablet and desktop */
#media(min-width:768px){
.item-wrap .elementor-widget-wrap>.elementor-element {
width: 33.33%;
}
}
(4) Here's the end result. Depending on the specifics of your page, we may need to tweak the CSS selectors in step 3. Give this a try and let me know how it goes.

How to click element with zero height with Capybara?

The error I'm getting is: element not interactable: element has zero size
I have an element with a button tag with text. However, the element.style has two attributes of 0px height (and 0px padding, if that matters).
The only workaround I've found is to interact with some other element that I can find (higher up in the hierarchy of the markup), and then use x and y offsets to click this button. However that ends up flaky because the size of the element can change, and the button is off to the lower right corner.
I'm willing to go the extra mile and calculate the proper coordinates, but I'm not able to figure out how to get the width of the element either. I'm also willing to just use some javascript to click as a last resort. Ideally I'd love to know if there is something more clean and elegant for this problem.
Thank you!
I think you can enable js for this test and use a trick for it.
Smth like that:
page.execute_script("$('#container img').css('height', '10px;')")
find('#container img').click
page.execute_script("$('#container img').css('height', '0')")
I ended up using actionbuilder to work around this problem, like this:
el = find('button', :text => '+ 1').native
actionbuilder = page.driver.browser.action # Use actionbuilder to workaround zero height button
actionbuilder.click(el).perform
I'm not sure if this is the way to go but that seems to have helped and maybe might help someone else out there.

Create a static div to hold an advertisement in a Compass Susy grid?

I have to accomodate an MREC advertisement in my layout. The ad is 300pixels wide, and cannot resize as the fluid grid otherwise contracts.
Further, the ad needs to be the first item on smartphone, before the headline block. So, on the breakpoint I am setting it to omega to push it "after" the headline, as in this screenshot (gray rules just to make it easier to see).
The headline is 8 cols, the ad is 4. All is fine except on ipad the ad column and the ad reduces to under 300 pixels, which we are not allowed to do. So, how to keep everything fluid except the ad container?
Set max/min widths on the container?
This is not hard to do, but it means the grid up top won't exactly match the flexible grid below. I assume that isn't an issue. You have to use some functions to lay out these two elements, but everything else can be done exactly as it was before.
You can keep the ad flexible down to a minimum width:
.ad {
#include span-columns(4 omega);
min-width: 300px; // you can use any width you want.
}
Or you can make the ad completely static:
.ad {
float: right;
width: columns-width(4); // you can use any width you want.
}
The important part is that you must not set a column width on the headline.
You have a few other options. The simplest might be to set right margins and padding equal to the static ad size (plus gutter):
.headline {
margin-right: columns-width(4) + $gutter-width;
}
Or, if you want that gutter to flex, try:
.headline {
margin-right: columns-width(4);
padding-right: gutter();
}
You can add clear: both; to the main content to make sure it clears the headline and ad.
If this approach doesn't work for you, try creating a new "formatting context" for the headline. One of the classic techniques is simply overflow: hidden;. Nicole Sullivan has a good blog post on how they do it for oocss, but it gets a bit more complex and you may not need all that.
UPDATE:
All these solutions require the ad coming first in the markup. The only way around that is if you know the height of the ad. In that case, you could position the ad absolutely rather than floating it, create space for it in the same way, and set a min-height on the headline (or row-container if you have one).

About finding pupil in a video

I am now working on an eye tracking project. In this project I am tracking eyes in a webcam video (resolution if 640X480).
I can locate and track the eye in every frame, but I need to locate the pupil. I read a lot of papers and most of them refer to Alan Yuille's deformable template method to extract and track the eye features. Can anyone help me with the code of this method in any languages (matlab/OpenCV)?
I have tried with different thresholds, but due to the low resolution in the eye regions, it does not work very well. I will really appreciate any kind of help regarding finding pupil or even iris in the video.
What you need to do is to convert your webcam to a Near-Infrared Cam. There are plenty of tutorials online for that. Try this.
A Image taken from an NIR cam will look something like this -
You can use OpenCV then to threshold.
Then use the Erode function.
After this fill the image with some color takeing a corner as the seed point.
Eliminate the holes and invert the image.
Use the distance transform to the nearest non-zero value.
Find the max-value's coordinate and draw a circle.
If you're still working on this, check out my OptimEyes project: https://github.com/LukeAllen/optimeyes
It uses Python with OpenCV, and works fairly well with images from a 640x480 webcam. You can check out the "Theory Paper" and demo video on that page also. (It was a class project at Stanford earlier this year; it's not very polished but we made some attempts to comment the code.)
Depending on the application for tracking the pupil I would find a bounding box for the eyes and then find the darkest pixel within that box.
Some psuedocode:
box left_location = findlefteye()
box right_location = findrighteye()
image_matrix left = image[left_location]
image_matrix right = image[right_location]
image_matrix average = left + right
pixel min = min(average)
pixel left_pupil = left_location.corner + min
pixel right_pupil = right_location.corner + min
In the first answer suggested by Anirudth...
Just apply the HoughCirles function after thresholding function (2nd step).
Then you can directly draw the circles around the pupil and using radius(r) and center of eye(x,y) you can easily find out the Center of Eye..

SVG/XAML: Defining a path which looks like an arrow

I'm trying to use SVG (really XAML) to define a path which looks like a downwards pointing arrow.
|
|
\ | /
\ | /
\ /
`
It is super-important that the edge of the arrow is sharp. I have tried with various combinations of M, L and z with no success.
You should take a look at the Marker element:
painting_Markers
I don't know about SVG but this will produce a sharp edge in XAML (tested in XAML Crancher)
<Path Data="M 10 0 L 10 20 0 10 0 15 12.5 27.5 25 15 25 10 15 20 15 0 z" Stroke="Black"/>
Have a look at this example from the SVG spec. You may want to tweak the 'stroke-miterlimit' property depending on the sharpness of the corner.
I'd recommend to use something like inkscape and design the arrow (just draw a line, select it, go to object > filling / contour > pattern and contourline > endmarker)
then save as pdf, rename the *.pdf to *.ai, open blend and import the ai file as adobe illustrator.
It's a bit difficult, but I still prefer it over using blend.
(i translated from german, so some menu items might be slightly different)
After having done some research, I don't think such a thing is possible to do with a single path easily. I did manage to solve it all by finding a library of XAML arrows and then doing some trickery to rotate the arrow I wanted the way I wanted it.
I agree with the above answer.
You (and your readers) should note the advent of Raphael (If they have not already) and also my offering for the SVG world.
I have been working for a year with Raphael and SVG. This link to my homepage might interest you (To those who are still listening and/or switched on to the power of Inkscape/Cross Browser SVG)
http://www.irunmywebsite.com/
This home page is a hybrid of the W3C SVG recommendations and the javascript library and beneath it are all the resources to get up and running quickly with SVG and Raphael.
Regards Chasbeen.

Resources