ISSUE-004 - Found the correct combination of CSS rules to get the centering I desire for both the div and img variants of the background image.

This commit is contained in:
Kyle Geib committed 2021-12-22 10:02:43 -05:00
1 parent b4ea27e8c6
commit f137b04e5e
3 files changed
+9 -13

No files matched your search

@@ -1,10 +1,9 @@
import { VideoFeedFrame, BackgroundImage, BackgroundImageDiv } from "./styles";
import { VideoFeedFrame, BackgroundImageDiv } from "./styles";
import bg from "../../../public/images/misc/bg-standin.jpg";
export default function VideoFeed() {
return <VideoFeedFrame centered={true}>
{/* <BackgroundImage src={bg} alt="formula one cars on track" /> */}
return <VideoFeedFrame centered>
<BackgroundImageDiv src={bg} />
</VideoFeedFrame>;
}
+6 -9
View File
@@ -11,27 +11,23 @@ export const VideoFeedFrame = styled.div<VideoFeedFrameProps>`
${({ centered = false }) => centered && css`
display: flex;
/* flex-direction: column; */
flex-direction: column;
align-items: center;
justify-content: center;
/* > * {
left: 10px;
} */
> div {
background-position: center;
}
`}
`;
VideoFeedFrame.displayName = "VideoFeedFrame";
export const BackgroundImage = styled.img`
height: 100%;
max-width: 100%;
object-fit: contain;
`;
BackgroundImage.displayName = "BackgroundImage";
/**
* A slight improvement to using a simple img in that we can resize the image
* (the video) to shrink slightly in the video feed frame if the browser window
* is too narrow.
*/
type BackgroundImageDivProps = {
src: string,
}
@@ -41,5 +37,6 @@ export const BackgroundImageDiv = styled.div<BackgroundImageDivProps>`
background-image: ${({ src }) => `url("${src}")`};
background-size: contain;
background-repeat: no-repeat;
background-position: 0% 50%;
`;
BackgroundImageDiv.displayName = "BackgroundImageDiv";