Responsive html with absolute position text inside relative positon picture - html

What I'm trying to do, is an HTML page split in two colors and
position a resizable image in the middle and on top show some positioned text.
I've managed to do it, but the problem is that when I resize the window,
image resizes just fine, but the text div loses its position.
.main {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
width: 100%;
height: 100%;
margin: auto;
border-radius: 0;
background: linear-gradient(to bottom, #f1b900 0%, #f1b900 50%, #000000 50%, #272660 50%, #272660 100%);
/* W3C */
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-moz-box-shadow: -3px 0 6px #4a5562;
-webkit-box-shadow: -3px 0 6px #4a5562;
box-shadow: -3px 0 6px #4a5562;
-moz-transition: all 300ms;
-webkit-transition: all 300ms;
width: 100%;
transition: all 300ms;
height: 100%;
}
.folderimg {
box-sizing: border-box;
background: url("folder.png") center center no-repeat;
background-size: contain;
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 75%;
height: 75%;
z-index: -1;
}
.foldername {
-webkit-transform: rotate(-5deg);
-moz-transform: rotate(-55eg);
-ms-transform: rotate(-5deg);
-o-transform: rotate(-5deg);
filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=3);
font-size: 4vmin;
position: absolute;
margin-top: 5%;
margin-left: 12%;
}
<div class="main">
<div class="folderimg">
<div class="foldername">Test Username</div>
</div>
</div>
jsfiddle
Some help would be really appreciable...

Use img tag instead of background-image, we can set size of container tag by size of img tag.
HTML
<div class="main">
<div class="folder">
<img src="https://s22.postimg.org/qi3kmv39d/folder.png">
<div class="foldername">Test Username</div>
</div>
</div>
CSS
.main {
/*...*/
display: flex;
align-items: center;
}
.folder {
position: relative;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
.folder img {
display: block;
height: auto;
width: auto;
max-width: 50vw;
max-height: 50vh;
}
.foldername {
position: absolute;
top: 5%;
left: 5%;
-webkit-transform: rotate(-5deg);
-moz-transform: rotate(-55eg);
-ms-transform: rotate(-5deg);
-o-transform: rotate(-5deg);
filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=3);
font-size: 3vmin;
}
Try this:
http://jsfiddle.net/w1om0h0o/2/
Hope it can help

Related

gear icon using a single div in pure css

I'm trying to create this icon using pure css & a single div
so far I've only managed to add 2 points like this:
:root {
--gear_radius: 5rem;
--gear_color: black;
--gear_thickness: 1.5rem;
--gear_pin_length: 1.5rem;
--gear_pin_gap: 1.5rem;
}
.gear {
margin: 5rem;
height: var(--gear_radius);
width: var(--gear_radius);
border-radius: 50%;
border: var(--gear_color) var(--gear_thickness) solid;
box-sizing: border-box;
position: relative;
}
.gear:before {
position: absolute;
content: "";
display: block;
height: var(--gear_pin_length);
width: var(--gear_thickness);
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(45deg);
box-shadow: 0 calc(var(--gear_thickness) * 2) 0 0 black, 0 calc(var(--gear_thickness) * -2) 0 0 black;
}
.gear:after {
position: absolute;
content: "";
display: block;
height: var(--gear_pin_length);
width: var(--gear_thickness);
left: 50%;
top: 50%;
transform: translate(-50%, -50%) rotate(-45deg);
box-shadow: 0 calc(var(--gear_thickness) * 2) 0 0 black, 0 calc(var(--gear_thickness) * -2) 0 0 black;
}
<div class="gear"></div>
How do I add 2 more points at the top and bottom? I don't know what approach to take from here?
The original picture of a gear wheel has an angle to the sides of each tooth.
However, I notice that in your part-solution you aren't worried about that and have parallel edges.
Here's a snippet that puts in all 6 teeth with parallel edges.
It uses before and after pseudo elements which had stripes as background and are rotated. The main div also has a stripe for a background but additionally a radial gradient with white and black circles.
.cog {
width: 30vmin;
height: 30vmin;
position: relative;
background-image: radial-gradient(white 0 35%, black 35% 70%, transparent 70% 100%), linear-gradient(to right, black, black);
background-size: 70% 70%, 25% 100%;
}
.cog::before,
.cog::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(to right, black, black);
background-size: 25% 100%;
z-index: -1;
}
.cog,
.cog::before,
.cog::after {
background-repeat: no-repeat;
background-position: center center;
transform-origin: center;
}
.cog::before {
transform: rotate(60deg);
}
.cog::after {
transform: rotate(120deg);
}
<div class="cog"></div>
Here's what it produces:
To get more sophisticated shape - such as the slope on the teeth, you could do more with gradients or just CSS clip-path (though by the time you've done this you probably might as well have created an SVG).
Well, of course SVG is better, but since your question is more of a challenge, here is my solution:
* {
margin: 0;
padding: 0;
}
.icon {
position: relative;
background: beige;
height: 160px;
width: 160px;
}
.wheel {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
width: 32px;
height: 32px;
background: beige;
border-radius: 50%;
border: solid 24px brown;
}
.cog {
position: absolute;
width: 24px;
height: 120px;
border-radius: 6px;
background: brown;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: auto;
}
.cog:nth-child(2) {
transform: rotate(45deg);
}
.cog:nth-child(3) {
transform: rotate(90deg)
}
.cog:nth-child(4) {
transform: rotate(135deg)
}
<div class="icon">
<div class="cogs">
<div class="cog"></div>
<div class="cog"></div>
<div class="cog"></div>
<div class="cog"></div>
</div>
<div class="wheel"></div>
<div>

Hexagon Image with Color Overlay?

I'm trying to design a website section that has 3 hexagons lined up. Inside the hexagons I want an image, which I have figured out how to do. BUT I also want to add a color overlay. Every time I try, the image disappears and the overlay gets doubled up in some places because of how I had to make the hexagon shape.
You can check out the code or see it live: https://jsfiddle.net/dfmcu4gt/
If you could tell me how to do this in tailwind CSS that would be even better.
#overlay {
background: rgba(9, 37, 90, 0.4);
object-fit: cover;
z-index: 2;
}
.hexagon {
position: relative;
width: 300px;
height: 173.21px;
margin: 86.60px 0;
background-image: url(https://www.uplers.com/wp-content/uploads/2020/06/Hiring-Web-Developers-Agencies-vs-Freelance-Portals.jpg);
background-size: auto 346.4102px;
background-position: center;
}
.hexagon1 {
position: relative;
width: 300px;
height: 173.21px;
margin: 86.60px 0;
background-image: url(https://www.octalsoftware.com.sg/blog/wp-content/uploads/2019/07/inhouse-developers-team.jpg);
background-size: auto 346.4102px;
background-position: center;
}
.hexagon2 {
position: relative;
width: 300px;
height: 173.21px;
margin: 86.60px 0;
background-image: url(https://blog.hubspot.com/hubfs/WordPress%20developer%20reviewing%20WordPress%20core.jpg);
background-size: auto 346.4102px;
background-position: center;
}
.hexTop,
.hexBottom {
position: absolute;
z-index: 1;
width: 212.13px;
height: 212.13px;
overflow: hidden;
-webkit-transform: scaleY(0.5774) rotate(-45deg);
-ms-transform: scaleY(0.5774) rotate(-45deg);
transform: scaleY(0.5774) rotate(-45deg);
background: inherit;
left: 43.93px;
}
/*counter transform the bg image on the caps*/
.hexTop:after,
.hexBottom:after {
content: "";
position: absolute;
width: 300.0000px;
height: 173.20508075688775px;
-webkit-transform: rotate(45deg) scaleY(1.7321) translateY(-86.6025px);
-ms-transform: rotate(45deg) scaleY(1.7321) translateY(-86.6025px);
transform: rotate(45deg) scaleY(1.7321) translateY(-86.6025px);
-webkit-transform-origin: 0 0;
-ms-transform-origin: 0 0;
transform-origin: 0 0;
background: inherit;
}
.hexTop {
top: -106.0660px;
}
.hexTop:after {
background-position: center top;
}
.hexBottom {
bottom: -106.0660px;
}
.hexBottom:after {
background-position: center bottom;
}
.hexagon:after {
content: "";
position: absolute;
top: 0.0000px;
left: 0;
width: 300.0000px;
height: 173.2051px;
z-index: 2;
background: inherit;
}
<div id="overlay" class="hexagon">
<div class="hexTop"></div>
<div class="hexBottom"></div>
</div>
<div class="hexagon1">
<div class="hexTop"></div>
<div class="hexBottom"></div>
</div>
<div class="hexagon2" style="">
<div class="hexTop"></div>
<div class="hexBottom"></div>
</div>

Skewing both top and bottom of div

I am trying to skew both the top and bottom of a div to create a shape that I can then insert a background pattern to however, after a few hours of research I can't really come up with a solid solution. I'm nearly there in the sense that all I need to do is to skew the bottom but am looking for some help or guidance on doing so.
I would like the bottom to mirror the skew of the top. Any suggestions?
#test {
position: relative;
width: 100%;
height: 400px;
}
.bg {
width: 50%;
height: 800px;
-webkit-transition: all 300ms ease-in;
background: black;
border-radius: 80px 0px 0px 80px;
position: absolute;
right: 0;
top: 0;
-ms-transform: skewY(-9deg);
-webkit-transform: skewY(-9deg);
transform: skewY(-9deg);
}
<section id="test">
<div class="bg"></div>
</section>
Example of what I currently have
https://jsfiddle.net/3atsj1e5/
With some rotation and perspective you can do it:
.box {
margin-left: auto;
width: 200px;
height: 450px;
transform-origin: right;
transform: perspective(100px) rotateY(-10deg);
border-radius: 40px 0 0 40px;
overflow: hidden;
}
.box::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: url(https://picsum.photos/id/1074/400/800) center/cover;
transform-origin:inherit;
transform: perspective(100px) rotateY(10deg);
}
body {
margin: 0;
background:#eee;
}
<div class="box"></div>

Blur Overlay expand on hover

I was wondering if someone can help me please, I am trying to expand a blur overlay on hover. I want the blur div to be centralised in the middle with a title and then on hover i would like the blur to expand out and overlay the background image. I have included an image of what I mean.
Does anyone know how to achieve this using css3?
any help would be appreciated.
Though a little jerky, this can work for you:
.outerdivs
{
background-color: #ddd;
background-image: url('http://loremflickr.com/400/200');
height: 200px;
position: relative;
width: 400px;
}
.outerdivs > h3
{
color: rgb(255, 102, 2);
height: 30px;
left: 0;
line-height: 30px;
margin-top: -15px;
position: absolute;
text-align: center;
top: 50%;
width: 100%;
z-index: 10;
}
.outerdivs .innerdivs
{
background-color: #fff;
background-image: url('http://loremflickr.com/400/200');
background-position: center center;
-webkit-filter: blur(2px);
filter: blur(2px);
height: 20%;
left: 0;
overflow: hidden;
position: absolute;
top: 50%;
transform: translateY( -50% );
transition: height 0.2s ease;
width: 100%;
z-index: 9;
}
.outerdivs .innerdivs img
{
left: 50%;
opacity: 0.8;
position: absolute;
top: 50%;
transform: translate( -50%, -50% );
}
.outerdivs:hover .innerdivs
{
height: 100%;
}
<div class="outerdivs">
<h3>Title</h3>
<div class="innerdivs">
<img src="http://loremflickr.com/400/200" alt="" />
</div>
</div>

Add pointer to the bottom of a div as a continuation of its background image

I'm looking for a way to stack divs, with a pointer leading into the next div that is a continuation of the previous div's background image.
I've looked around and I've seen some options, but in all of them the bottom div has to be a solid color.
For example: http://jsfiddle.net/nhqKb/
#container{
height: 300px;
background: url('http://farm8.staticflickr.com/7358/9532233404_58763bd668_b.jpg') no-repeat;
position: relative;
}
#one {
position: absolute;
width: 100px;
left: 0;
bottom: 0;
border-bottom: 20px solid green;
border-right: 20px solid transparent;
}
#two {
position: absolute;
left: 120px;
bottom: 0;
right: 0;
border-bottom: 20px solid green;
border-left: 20px solid transparent;
}
<div id="container">
<div id="one"></div>
<div id="two"></div>
</div>
Is there any way to implement this using divs with background images instead of solid colors?
You can use skewX and pseudo elements to make this.
#container {
background: url('https://images.unsplash.com/photo-1440635592348-167b1b30296f?ixlib=rb-0.3.5&q=80&fm=jpg&w=1080&fit=max&s=a029f986631f264fdbc8c0272cab9c40') no-repeat;
height: 300px;
position: relative;
overflow: hidden;
}
#one {
background-color: rgba(0, 0, 0, 0.3);
bottom: 0;
left: 0;
padding-bottom: 15px;
position: absolute;
width: 100%;
}
#one:before,
#one:after {
background-color: inherit;
bottom: 100%;
content: '';
padding-bottom: inherit;
position: absolute;
width: 50%;
}
#one:before {
right: 50%;
-ms-transform-origin: 100% 100%;
-webkit-transform-origin: 100% 100%;
transform-origin: 100% 100%;
-ms-transform: skewX(45deg);
-webkit-transform: skewX(45deg);
transform: skewX(45deg);
}
#one:after {
left: 50%;
-ms-transform-origin: 0 100%;
-webkit-transform-origin: 0 100%;
transform-origin: 0 100%;
-ms-transform: skewX(-45deg);
-webkit-transform: skewX(-45deg);
transform: skewX(-45deg);
}
HTML code:
<div id="container">
<div id="one"></div>
</div>