I have a problem with background positioning.
I want background image moves out of it's container and i want to do it with background-position: 150% center for example.
Now the problem is in different resolutions, these % values have differences.
For example, in 1360px resolution, my background image moves out with value of 175% of horizontal.
But in 360px resolution, my background image moves out with value of 4500% of horizontal.
Do you have any solution for this problem?
thank you.
.airplane{
width: 100%;
height: 126px;
background-image: url("../img/book.png");
background-repeat: no-repeat;
position: absolute;
background-position: 175% center;
}
<div class="book">
</div>
Related
How you Change MUI icon border thickness
suppose this icon is having thickness how to make setting icon border lighter
There is a trick with css (stroke must have the same color as your background)
<YourMuiIcon sx={{ stroke: "#ffffff", strokeWidth: 1 }} />
I am looking to prevent horizontal scrolling on my portfolio site in mobile safari. The design features content div's that are off the screen, until a user clicks a menu item then they transition onto the screen. This works fine on desktop, but on mobile it leaves a ton of extra white space that a user can scroll horizontally into.
the site is http://www.robiannone.com
I have used this viewport tag
<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1" />
and I have tried using overflow-x:hidden with a media query without any luck. When I add overflow-x:hidden to the html or body tag nothing happens, however when I add it to both the html and body tag the site breaks, and puts a scroll bar near the header. I have searched for other solutions but have so far not come up with anything to help. Will it just not work because I am intentionally placing content off screen?
Much thanks for any help you can provide!
Here is the css for the content div's:
.web {
width: 953px;
height: 150px;
position: absolute;
margin-top:40px;
margin-left:0px;
z-index:1;opacity:0;
padding:7px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
/*Transition Effect, Thanks css-tricks.com! */
-webkit-transition: opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
-moz-transition: opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
-o-transition: opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
-ms-transition: opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
transition: opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
}
.video {
width: 953px;
height: 150px;
position: absolute;
margin-top:40px;
margin-left:0px;
z-index:500;
overflow:hidden;
opacity:0;
padding:7px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
/*Transition Effect, Thanks css-tricks.com! */
-webkit-transition:opacity 1s linear 0.3s, height 1s linear 0.3s, z-index 0.1s linear, margin-top 0.9s ease, margin-left 1.5s ease;
-moz-transition:opacity 1s linear 0.3s, height 1s linear 0.3s, z-index 0.1s linear, margin-top 0.9s ease, margin-left 1.5s ease;
-o-transition:opacity 1s linear 0.3s, height 1s linear 0.3s, z-index 0.1s linear, margin-top 0.9s ease, margin-left 1.5s ease;
-ms-transition:opacity 1s linear 0.3s, height 1s linear 0.3s, z-index 0.1s linear, margin-top 0.9s ease, margin-left 1.5s ease;
transition:opacity 1s linear 0.3s, height 1s linear 0.3s, z-index 0.1s linear, margin-top 0.9s ease, margin-left 1.5s ease;
}
.about {
width: 953px;
height: auto !important;
position: absolute;
margin-top:40px;
z-index:9000;
opacity:0;
padding:7px;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
-o-border-radius: 10px;
-ms-border-radius: 10px;
border-radius: 10px;
border-radius: 10px;
/*Transition Effect, Thanks css-tricks.com! */
-webkit-transition:opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
-moz-transition:opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
-o-transition:opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
-ms-transition:opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
transition:opacity 1s linear 0.3s, height 1s linear 0.2s, z-index 0.1s linear, margin-top 1.5s ease, margin-left 0.9s ease;
/*Classes that Div's take once clicked*/
.prime{
width: 953px;
height: 750px;
background:rgba(255,255,255,.9);
margin-left:0px;
position: absolute;
margin-top:75px;
z-index:9001;
opacity:1;
overflow:auto;
}
.third{
width: 953px;
height: 200px;
opacity: 0.0 !important;
position: absolute;
margin-top:-499px;
margin-left:1810px;
z-index:1;
overflow:hidden;
}
.secondary{
width: 953px;
height: 200px;
opacity: 0 !important;
position: absolute;
margin-top:499px;
margin-left:-1810px;
z-index:500;
overflow:hidden;
}
I have just solved a similar problem by using a media query to set overflow:hidden on the element when it is loaded onto a small screen.
So I have in my css:
overflow:visible on my div with all my content in waiting to slide
overflow-x:hidden on the html tag to get rid of the side ways scroller that this creates due to content width
a media query to set overflow:hidden on the content div if the screen is small
I figured from a user perspective that when the screen was larger than 1024px they would benefit from the additional visual impact of having content ready to slide onto the screen from either side, but when viewing a 960px wide site on 1024px or smaller this impact would be lost as the content is pretty much invisible anyway.
html
{
overflow-x:hidden;
}
#media only screen and (max-width: 1024px)
{
overflowing_content_div { overflow:hidden; }
}
there may a less hacky solution to this and one that will be future proof enough to cope with mobile devices with higher screen resolutions than 1024px, if so I would like to hear it and would prefer it to be voted as the main answer
I have a XY line chart plot and a css file where I set chart features.
I can't figure out how to avoid the white border along the chart
My css settings are:
.chart-plot-background{
-fx-padding:0px;
-fx-font-family: Verdana;
-fx-background-color: linear-gradient(to bottom right, lightsteelblue, black);
}
.chart-content{
-fx-background-color: linear-gradient(to bottom right, lightsteelblue, black);
-fx-padding:30px;
}
I would like to fill the frame with same color without the white border.
Thanks
I have find a solution: it seems these white lines act as "border", so I have added in css file these instructions:
-fx-border-color: linear-gradient(to bottom right, lightsteelblue, black);
-fx-border-width: 5;
-fx-border-insets: -5;
Not sure if this is the best solution, any suggestions appreciated.
I am designing fluid layout pages (defining everything in % in CSS) for multiple devices (desktop/tablet/mobile)
Now while I do understand that giving width:100% takes the entire viewport available width (i.e. available browser area) and accordingly calculates all the % widths ?
But my question is how do I set or convert any "pixel" height to % height for defining fluid layouts CSS?
You have to give your body styles like so...
body {width: 100%; height: 100%; min-height: 100%; height: auto;}
As your body has a height of the viewport, anything that is a child of it can be specified using percentage, like a div 50% of the screen would be...
body div {height: 50%; min-height: 50%; height: auto;}
Remember % is inherited from its parent.
A CAShapeLayer uses a CGPathRef to draw it's stuff. So I have a star path, and I want a smooth drop shadow with a radius of about 15 units. Probably there is some nice functionality in some new iPhone OS versions, but I need to do it myself for a old aged version of 3.0 (which most people still use).
I tried to do some REALLY nasty stuff:
I created a for-loop and sequentially created like 15 of those paths, transform-scaling them step by step to become bigger. Then assigning them to a new created CAShapeLayer and decreasing it's alpha a little bit on every iteration. Not only that this scaling is mathematically incorrect and sucks (it should happen relative to the outline!), the shadow is not rounded and looks really ugly. That's why nice soft shadows have a radius.
The tips of a star shouldn't appear totally sharp after a shadow size of 15 units. They should be soft like cream. But in my ugly solution they're just as s harp as the star itself, since all I do is scale the star 15 times and decrease it's alpha 15 times. Ugly.
I wonder how the big guys do it? If you had an arbitrary path, and that path must throw a shadow, how does the algorithm to do that work? Probably the path would have to be expanded like 30 times, point-by-point relative to the tangent of the outline away from the filled part, and just by 0.5 units to have a nice blending.
Before I re-invent the wheel, maybe someone has a handy example or link?
A shadow is a translucent grayscale mask of the shape of an object blurred and offset.
CGContextSetShadowWithColor and CGContextSetShadow are how this is done on iPhone. You set the shadow then draw something and a shadow is also applied.
A CAShapeLayer does not have an easy option to apply a shadow. You will have to create a custom view or layer and set the shadow before drawing your shape.
I have not tried it, but the following might work:
#interface ShadowShapeLayer : CAShapeLayer
#end
#implementation ShadowShapeLayer
-(void) drawInContext:(CGContextRef)context {
CGContextSaveGState( context );
CGContextSetShadow( context , CGSizeMake( 5 , 5 ) , 15 );
[super drawInContext:context];
CGContextRestoreGState( context );
}
#end
Edit: Thanks Miser.
I asked myself the same question. I'm not an expert on this topic at all, but I had the following thought: Physically, one point of a drawing should result in a circular (or elliptical), semi-transparent shadow. So an entire drawing, which consists of multiple points, should result in the combination of a lot of such circular shadows.
So I painted a little shadow in Photoshop (brush tool, size 7, opacity 33%, color #3b3b3b). It's hardly visible:
Then I wrote a small HTML with Javascript just to try and see what it looks like (definitely not the ideal technique :-):
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Title</title>
<script type="text/javascript" language="javascript">
function pageload() {
var drawingContainerElem = document.getElementById("drawing-container");
var shadowContainerElem = document.getElementById("shadow-container");
this.drawDot = function(x, y) {
var imgElem = document.createElement("img");
imgElem.style.left = x + "px";
imgElem.style.top = y + "px";
imgElem.src = "blue-dot.png";
drawingContainerElem.appendChild(imgElem);
}
this.drawShadow = function(x, y) {
var imgElem = document.createElement("img");
imgElem.style.left = x + "px";
imgElem.style.top = y + "px";
imgElem.src = "soft-shadow.png";
shadowContainerElem.appendChild(imgElem);
}
this.drawDotAndShadow = function(x, y) {
drawShadow(x - 5, y - 1);
drawDot(x, y);
}
for (var x = 50; x < 70; x ++) {
for (var y = 50; y < 58; y ++) {
drawDotAndShadow(x, y);
}
}
for (var x = 0; x < 15; x ++) {
for (var y = 0; y < x; y ++) {
drawDotAndShadow(69 + 15 - x, 54 + y);
drawDotAndShadow(69 + 15 - x, 54 - y);
}
}
}
</script>
<style type="text/css">
#drawing-container {
position: absolute;
left: 2em;
top: 2em;
width: 400px;
height: 400px;
z-index: 2;
}
#shadow-container {
position: absolute;
left: 2em;
top: 2em;
width: 400px;
height: 400px;
z-index: 1;
}
#drawing-container img {
position: absolute;
}
#shadow-container img {
position: absolute;
}
</style>
</head>
<body onload="javascript:pageload()">
<div id="drawing-container"></div>
<div id="shadow-container"></div>
</body>
</html>
This is the result:
Probably, there's a lot of room for optimization, and of course you wouldn't really render it using javascript in this way... Maybe you can find a way how to render this efficiently on the iPhone? If yes, let me know!
Possible improvements:
Make the center of the shadow circle darker (more opacity), and the rest lighter (less opacity) to achieve a core shadow.
Scale the shadow: Make it a bit smaller, to achieve a depth effect.