Could not find anything on this for the life of me. I simply want to display 1 little icon, multiple times on the same row,
But want to rotate each instance a bit more then the last one. So by the end of the row, the last icon is completely flipped compared to the first icon.
Here is my attempt: (thanks)
<div class="container">
<p class="one">I don't</p><p class="two">really want </p><p class="three">any</p><p class="four">words here</p>
</div>
<style>
p.one {
float:left;
image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
}
p.two {
float:right;
background-image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
transform: rotate(60deg);
}
p.three {
float:right;
background-image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
transform: rotate(120deg);
}
p.four {
float:right;
background-image: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png");
transform: rotate(180deg);
}
</style>
Positioning system in a row can be achieved with 2 ways. The first and easy way is bootstrap grid system , so your problem could be solved like this
<div class="container-fluid">
<div class="col-sm-3">img</div>
<div class="col-sm-3">img</div>
<div class="col-sm-3">img</div>
<div class="col-sm-3">img</div>
</div>
Replace the img keyword i wrote with your images and transform them as you like inside css and you will be all set.
The second and more advanced way to place images in a row inside a div is position css attribute.
position:relative;
top:40px;
left:70px;
This will place the element in a specific place relative to its parent , so then you could place them wherever you want.
There are definitely more ways to do this like flexbox and more , but i totally recommend using bootstrap grid system because its easy to use and most of all responsive!
I think you should separate the text from rotating. something like this
<div class="container">
<p><span class="one"></span>I don't</p>
<p><span class="two"></span>really want </p>
<p><span class="three"></span>any</p>
<p><span class="four"></span>words here</p>
</div>
and in css use image as background image
.container {width:100%}
.container p { float:left; margin:0 20px}
.container p span {
width:20px; height:20px; display:block;
background: url("http://www.itel.am/assets/ico/iconsForSocials/gl.png") no-repeat left center; float:left;
}
.two { transform: rotate(60deg); }
.three { transform: rotate(120deg); }
.four { transform: rotate(180deg); }
here is the working sample
Related
I've been looking for a way to create a video background (preferably an HTML5 / CSS-only solution) for a header DIV on a little micro-site.
Obviously, there are a lot of resources on how to do this if you want a fixed background (position:fixed;) that'll apply to the entire page or if your DIV has a fixed height, but I want to apply it to a single DIV (within the Bootstrap framework, coincidentally) with a dynamic height attribute.
It would have a min-height value of 100vh, but the DIV's height should be able to be larger depending on the content within it (in this scenario, I have a couple of introductory paragraphs that would likely require some scroll on smaller screens).
I kind of got it half way there with my original approach, but a little bit of my video extends beyond the container DIV and giving the container an overflow:hidden; attribute doesn't help.
Here's a CodePen with the code below + Bootstrap so that you can see what I'm talking about in action.
Screenshot of the video extending into the next DIV, just in case.
This is essentially the pertinant code to my 90% of the way there option... (it looks like the video takes the 100% width this way, but it doesn't crop the height to the container):
<div class="content contain-header">
<div class="container">
<div class="row main-header">
<video autoplay loop poster="images/clouds.jpg" id="bgvid">
<source src="images/clouds.webmhd.webm" type="video/webm" />
<source src="images/clouds.mp4" type="video/mp4" />
</video>
<div class="col-md-2 col-xs-1">
</div>
<div class="col-md-8 col-xs-10">
<img src="images/logo.svg" class="header-logo" />
<h1 id="header-you">Wow</h1>
<p>Business model canvas rockstar user experience founders handshake. Startup responsive web design bootstrapping first mover advantage disruptive crowdfunding. User experience iteration seed money rockstar holy grail deployment prototype gen-z backing influencer handshake success. Virality growth hacking innovator product management iPad.</p>
<p>Crowdsource marketing non-disclosure agreement graphical user interface bootstrapping market research & development:</p>
<p class="punch">Stratup Ipsum!</p>
<p class="continue"><span class="glyphicon glyphicon-menu-down"></span></p>
</div>
<div class="col-md-2 col-xs-1">
</div>
</div>
</div>
</div>
And the relevant CSS, in SCSS format (+Bootstrap v3.3.5):
.contain-header {
background-color: rgba(0, 0, 0, 0.6);
.main-header {
min-height:100vh;
display:block;
color:$color-white;
video#bgvid {
position:absolute;
top:50%;
left:50%;
min-width:100%;
min-height:100%;
width:auto;
height:auto;
z-index:-100;
-ms-transform: translateX(-50%) translateY(-50%);
-moz-transform: translateX(-50%) translateY(-50%);
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
background: url(../images/clouds.jpg) no-repeat;
background-size: cover;
}
video {
display:block;
}
.header-logo {
max-width:40%;
height:auto;
margin:0 auto;
display:block;
padding-top:20px;
}
h1#header-you {
text-transform:uppercase;
text-align:center;
font-family:$tultra;
}
p {
font-size:2rem;
}
p.punch {
font-size:2.3rem;
text-align:center;
margin-top:30px;
}
.continue {
text-align:center;
padding-top:20px;
padding-bottom:40px;
a, a:visited {
color:$color-white;
text-decoration:none;
}
a:hover {
color:$color-gray-icons;
text-decoration:none;
}
}
#media screen and (max-width: 767px) {
p {
font-size:1.4rem;
}
p.punch {
font-size:1.8rem;
}
}
}
}
Try adding this to the start of your styles
.contain-header {
position: relative;
overflow: hidden;
background-color: rgba(0, 0, 0, 0.6);
...
The position relative on the contain-header means that the video min-height, min-width etc. is relative to it.
I'm working on a website where I want an image to straight away take up the screen. I want to make it take up the available screen but when you begin to scroll down I want a div to appear with the text and information. I do not mind if only some of the image is showing (like the bottom is slightly missing). I can do it, but it doesn't work on other resolutions.
I would rather not use javascript but if it is the only way I don't mind.
NEW another way of explaining what I'm trying to do is, I want the margin from the top of a div relative to the screen, so that on all screens the div appears as soon as you begin to move down the page.
I think you are asking about Parallax.
Explore a bit on Parallax in Wiki and see some samples here
Try this
HTML
<html>
<body>
<div class="imageDiv"></div>
<div class="contentDiv">
<h1>This is heading</h1>
<p>This is Paragraph</p>
</div>
</body>
<html>
CSS
*{
margin:0;
padding:0;
}
html, body{
width:100%;
height:100%;
}
.imageDiv{
width:100%;
height:100%;
background:url(http://www.hdwallpapersimages.com/wp-content/uploads/2015/06/Swing-02124.jpg) no-repeat top center #000;
}
No jquery has used
It sounds like you are trying to build a parallax website. Its possible to do this with only css and no java script. If you check you Keith Clark's blog post it should give you a good idea. http://keithclark.co.uk/articles/pure-css-parallax-websites/
.parallax {
perspective: 1px;
height: 100vh;
overflow-x: hidden;
overflow-y: auto;
}
.parallax__layer {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.parallax__layer--base {
transform: translateZ(0);
}
.parallax__layer--back {
transform: translateZ(-1px);
}
<div class="parallax">
<div class="parallax__layer parallax__layer--back">
...
</div>
<div class="parallax__layer parallax__layer--base">
...
</div>
</div>
Let's say I have an html div (or some such element) featuring miscellaneous nested elements. I want to be able to design my layout using pixel positioning and pixel sizes (not percentages) and then scale up the resulting UI to fit the screen (while maintaining its aspect ratio).
So my question is how can I scale up an arbitrary html element and it's children while maintaining their layout?
Here's an example of a UI that I might want to scale up: http://jsfiddle.net/8dodovmn/2/
<div id="myUI" style="width:400px; height:300px; background-color:blue; position:relative;">
<div style="border:1px solid red; position:absolute;left:100px; top: 100px; width:100px; height:100px; text-align:center;">
<button style="height:50px; margin-top:20px;">Submit</button>
</div>
</div>
A CSS scale transform seemed like a good idea, but it doesn't work:
http://jsfiddle.net/Lqozzpmg/1/ The layout of the elements is not preserved.
#myUI
{
-webkit-transform: scale(2); /* Doesn't work, though it seems like it should. Layout of nested elements is not maintained */
}
Try adding a containing element so the #myUI element can be positioned in relation to it, then change your CSS a tiny bit. See fiddle here or text below
HTML
<div id="box">
<div id="myUI" style="width:400px; height:300px; background-color:blue; position:relative;">
<div style="border:1px solid red; position:absolute;left:100px; top: 100px; width:100px; height:100px; text-align:center;">
<button style="height:50px; margin-top:20px;">Submit</button>
</div>
</div>
</div>
CSS CODE
#box {
width:50vw;
height:50vh;
text-align:center;
}
#myUI {
transform: translateY(-50%);
-webkit-transform:translateY(-50%);
top:50%;
transform: scale(2);
/* Doesn't work, though it seems like it should. Layout of nested elements is not maintained */
transform-origin: 0%;
}
As you may imagine, the #box size is for demo purposes, you can use anything you want. You don't need to use viewport sizes either, I just used them just to show a not so commonly used CSS measure, but again, use what you like
I have a div with some text in it and "on hover", I want to display another div with some other text.
The problem is that the text from the first div comes through to the second and everything seems mingled up. I would like the second div to completely cover the first one.
Here is the jsfiddle
HTML
<div class="outer_box">
<div class="inner_box">
Main</div>
<span class="caption">Caption</span>
</div>
CSS
.outer_box {
width:100px;
height:100px;
background-color:orange;
}
.inner_box{
width:100px;
height:100px;
position:absolute;
}
.caption {
width:100px;
height:100px;
background:black;
color:rgba(255,255,255,1);
opacity:0;
}
.outer_box:hover .caption{
opacity:1;
}
Thanks!
.inner_box:hover {
opacity: 0.0;
}
You need to style the text from the first div so that it disappears on hover:
.inner_box:hover .text {
visibility:hidden;
}
Add this to your CSS:
.outer_box:hover, .inner_box:hover {
opacity:0;
}
If you will notice, I made sure to include the .outer_box:hover selector in case your intention ever was to make the outer box significantly larger than the inner box.
More useful information about the behavior of the opacity property can be found here: http://www.w3schools.com/cssref/css3_pr_opacity.asp
I want use three div to create a round effect,like
<div class="wrapper">
<div class="left-corner"></div>
<div class="center-repeat"></div>
<div class="right-corner"></div>
</div>
the .left-corner and .right-corner have a only corner background image
css:
.wrapper
{
width:100%
height:110px;
}
.left-corner
{
background:...
width:110px;
height:110px;
float:left
}
.right-corner
{
background:...
width:110px;
height:110px;
float:right
}
but how should I render the middle div
I tried use width:100% but the corner div will be push and become another row
how can I set the three div in a line and look normal?
If your wrapper is set in percentages, then I would think it best to keep it's children in percentages as well, perhaps use a 33%, 33% and 34% to get the 100%. For the middle, or center-repeat I think you may need to use float: left as well, so it snugs up to the left-corner.
Have you tried using border-radius property?
You can just use the center div and border radius any other corner.
https://developer.mozilla.org/en/CSS/border-radius
Support for "border-radius" in IE
<div class="wrapper">
... content inside wrapper ...
</div>
.wrapper
{
width: 100%;
height: 110px;
border-radius: 5px;
}
Hi i thing you should this
Css
.wrapper
{
width:100%
height:110px;
overflow:hidden;
border:solid 5px black;
border-radius:25px;
}
.left-corner
{
background:red;
width:110px;
height:110px;
float:left
}
.right-corner
{
background:green;
width:110px;
height:110px;
float:right
}
.center-corner{
width:100%;
background:yellow;
height:110px;
}
HTML
<div class="wrapper">
<div class="left-corner">Left</div>
<div class="right-corner">Right</div>
<div class="center-corner">Center</div>
</div>
Live demo http://jsfiddle.net/pTxrW/
Here's my try: jsfiddle.
Left and right corners are 10px less height than center block so it's easier to see borders between them.