Related
Currently still doing my project and I'm trying to find out how to position headings in certain places. Figure 1 is my final goal for my headings to look like.
[Figure 1][1]
Currently this is what mine looks like (Figure 2), I am struggling to position the heading to a similar spot, every time I do, the paragraphs and the navbar move further down leaving a big white gap between the headings & paragraphs.
Also was wondering how would I level out the image with the text & navbar?
Thanks in advance, much appreciated.
[Figure 2][2]
I believe this is what you wanted:
preview
Basically, you could wrap the header (image + text) into a CSS flexbox, and the rest of the stuff into another flexbox. I edited the CSS file to reflect these changes. Hope this helps! Let me know if you have any other questions.
Here's a link to the jsfillde: https://jsfiddle.net/rzLbkw9m/
Here's the html file:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="holiday.css" rel="stylesheet" type="text/CSS">
<title>Task 4</title>
</head>
<body>
<div class="header-container">
<div class="header-image">
<img src="https://st.depositphotos.com/1115174/1875/v/450/depositphotos_18752455-stock-illustration-summer-beach-vacation-background.jpg" alt="Holiday" width="400" height="200" align="left">
</div>
<div class="header-text">
<h1>Holiday Time</h1>
<h3>Get away from it all</h3>
</div>
</div>
<div class="row">
<div class="list-column">
<ul class="list">
<li>Destinations</li>
<li>Deals</li>
<li>Flights</li>
<li>Cruise</li>
<li>Extras</li>
<li>Money</li>
</ul>
</div>
<div class="main-column">
<div class="paragraph">
<p>
<img src="https://images.pexels.com/photos/88212/pexels-photo-88212.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260" alt="Holiday" width="220" height="150" align="right" class="intext-img">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Donec ultrices libero eu eros viverra, eget tristique ipsum commodo. Phasellus tempus a erat quis hendrerit. Quisque ipsum felis, vestibulum sed finibus vel, molestie id ante. Morbi metus leo, dictum nec pellentesque nec, condimentum quis magna. Praesent est turpis, pharetra non fermentum sed, elementum ac ante. Integer sodales metus id rutrum hendrerit. Phasellus vel dapibus massa, ut aliquet arcu. Ut consectetur feugiat neque, sed sagittis dui rutrum eget. Maecenas commodo mattis enim quis lacinia. Duis in ipsum vitae mi laoreet dignissim. Nullam consequat velit at magna commodo, in fringilla enim rutrum. Cras at augue sed nisl ultricies lobortis. Praesent rhoncus lectus facilisis, rhoncus purus et, luctus eros. Nunc eros nisi, finibus sit amet urna quis, posuere ultrices mauris.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc quis lorem vel neque bibendum iaculis vel id tellus. Nulla auctor elit vitae sollicitudin ultrices. Fusce molestie dictum neque, et dictum magna iaculis eget. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed volutpat, augue eget tincidunt feugiat, felis mi vulputate sem, eu mattis nisi quam sit amet est. Cras eu sem nec metus iaculis tempus sit amet non sapien. Aenean id odio semper purus dignissim elementum. Vestibulum faucibus mi ac odio hendrerit venenatis. Cras rhoncus diam magna, at placerat quam rutrum ut.
</p>
</div>
<div class="paragraph">
<p>
<img src="https://i.pinimg.com/474x/c6/60/24/c66024ea79527d9bbafe79ed171558b9--luxury-travel-luxury-hotels.jpg" alt="Holiday" width="220" height="150" align="right" class="intext-img">
Quisque fringilla sodales lorem eget rhoncus. Curabitur pulvinar blandit justo nec volutpat. Mauris bibendum lobortis quam et aliquam. Nulla dictum varius est, sed fringilla ante volutpat ac. Sed tempus dolor diam, ac porta ligula sagittis ac. Morbi vitae nisi porttitor, sollicitudin urna non, tempus justo. Donec vel vulputate est. Donec aliquet vitae velit eu interdum. Quisque et facilisis diam. Duis rutrum faucibus purus at tempus. Mauris auctor tincidunt mauris, quis porttitor magna aliquam molestie. Aliquam efficitur, ex sed finibus porta, tellus diam dictum arcu, ac egestas quam enim tristique velit. Integer volutpat tortor et tortor consequat tincidunt. Donec imperdiet libero vitae sapien commodo, eget pretium libero eleifend. Sed mi felis, porttitor vel blandit laoreet, pretium a felis. Duis in erat interdum, rutrum lectus viverra, pellentesque elit. Sed imperdiet massa ullamcorper mauris tempus, at euismod nibh convallis. In sapien lorem, lacinia eget viverra sit amet, suscipit in diam. Phasellus at sapien eu orci pellentesque eleifend suscipit eu diam. Vivamus quis nibh id sem placerat rutrum. Nunc pellentesque aliquet congue.
Nam at eros elementum, venenatis nibh vel, volutpat mi. Donec varius sapien ipsum, sed sagittis ligula iaculis hendrerit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Praesent pharetra ante eget purus rhoncus, ac pharetra eros fermentum. Etiam porta nec leo pretium gravida. Integer a nulla quam. In ullamcorper, nibh id efficitur porttitor, lacus mi semper nisi, id pulvinar ex leo at mi. Vestibulum placerat lacus vitae velit laoreet, in efficitur risus convallis. Nunc at sagittis dolor, eu gravida nunc. In hac habitasse platea dictumst. Mauris vitae lobortis ipsum, quis rhoncus mauris. Ut eget nibh sed dolor sollicitudin dictum efficitur ac ligula. Nullam ut nulla sit amet leo varius tincidunt.
</p>
</div>
</div>
</div>
<div class="footer"> Contact: 0191 227 1111</div>
</body>
</html>
Here's the css file:
/* header */
.header-container {
display: flex;
align-items: center;
border: 1px solid lightblue;
}
.header-text {
margin-left: 25px;
}
.header-text h1 {
color: purple;
font-size: 48px;
}
.header-text h3 {
margin-left: 20px;
}
/* navbar */
.list-column {
flex: 30%;
align-self: flex-start;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
}
li a {
display: block;
color: #000;
padding: 8px 16px;
text-decoration: none;
}
li a:first-of-type {
padding-top: 2px;
}
/* main content */
.row {
margin-top: 10px;
display: flex;
align-items: flex-start;
}
.paragraph {
margin-bottom: 25px;
}
.intext-img {
margin-top: 5px;
margin-left: 10px;
margin-bottom: 10px;
}
p {
font-size: 18px;
margin: 0px;
}
/* footer */
.footer {
position: absolute;
right: 0;
bottom: 0;
left: 0;
padding: 0.8rem;
text-align: left;
background-color: #64A3D6;
}
create a div around h1 and h3
.header{
position: relative;
top: 50%;
transform: translateY(-50%);
}
this will put the header in the middle of the area vertically. make sure the padding or margin is minimal
I'm learning about floats at the moment, and I have a question.
Looking at the code here, I am wondering if I can make it so that the background-color property only applies to the paragraph, and not the image.
I have tried putting clear: both inside the p's declaration, however, this makes the paragraph goes under the image, which is not what I wanted.
body{
background-color: #cccccc;
}
.wrapper{
max-width: 960px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
}
img{
width: 300px;
float: left;
margin: 20px;
}
p{
background-color: rgb(0,200,255);
padding: 20px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<div class="wrapper">
<img src="https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fwallpapercave.com%2Fwp%2FTvGvWdR.jpg&f=1" />
<p>Ac turpis egestas integer eget aliquet nibh praesent tristique magna. Cras adipiscing enim eu turpis egestas pretium
aenean. Vulputate eu scelerisque felis imperdiet proin fermentum leo vel orci. Ante metus dictum at tempor commodo
ullamcorper a lacus. Risus nec feugiat in fermentum posuere urna. In nisl nisi scelerisque eu ultrices vitae. Fringilla
urna porttitor rhoncus dolor purus. Id leo in vitae turpis massa sed. Viverra aliquet eget sit amet tellus cras
adipiscing. Elementum eu facilisis sed odio morbi quis commodo. Pellentesque elit eget gravida cum sociis natoque
penatibus et magnis. Urna condimentum mattis pellentesque id nibh. Tincidunt id aliquet risus feugiat in. Tortor
posuere ac ut consequat semper viverra nam libero. Tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras
fermentum. Pharetra magna ac placerat vestibulum lectus.</p>
</div>
</body>
</html>
All suggestions are appreciated! Thanks in advance!
Reset the background-color of the image
background-color: #ffffff
And if you want that the margin is also white, you could use a border instead of margin.
border: 20px solid #ffffff
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<div class="wrapper">
<img src="https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fwallpapercave.com%2Fwp%2FTvGvWdR.jpg&f=1" />
<p>Ac turpis egestas integer eget aliquet nibh praesent tristique magna. Cras adipiscing enim eu turpis egestas pretium
aenean. Vulputate eu scelerisque felis imperdiet proin fermentum leo vel orci. Ante metus dictum at tempor commodo
ullamcorper a lacus. Risus nec feugiat in fermentum posuere urna. In nisl nisi scelerisque eu ultrices vitae. Fringilla
urna porttitor rhoncus dolor purus. Id leo in vitae turpis massa sed. Viverra aliquet eget sit amet tellus cras
adipiscing. Elementum eu facilisis sed odio morbi quis commodo. Pellentesque elit eget gravida cum sociis natoque
penatibus et magnis. Urna condimentum mattis pellentesque id nibh. Tincidunt id aliquet risus feugiat in. Tortor
posuere ac ut consequat semper viverra nam libero. Tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras
fermentum. Pharetra magna ac placerat vestibulum lectus.</p>
</div>
</body>
</html>
CSS:
body{
background-color: #cccccc;
}
.wrapper{
max-width: 960px;
margin: 0 auto;
padding: 20px;
background-color: #ffffff;
}
img{
width: 300px;
float: left;
margin: 20px;
}
p{
background-color: rgb(0,200,255);
padding: 20px;
clear: both;
}
Try adding another wrapper div around p tag:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
</head>
<body>
<div class="wrapper">
<img src="https://proxy.duckduckgo.com/iu/?u=http%3A%2F%2Fwallpapercave.com%2Fwp%2FTvGvWdR.jpg&f=1" />
<div class="clear">
<p>Ac turpis egestas integer eget aliquet nibh praesent tristique magna. Cras adipiscing enim eu turpis egestas pretium
aenean. Vulputate eu scelerisque felis imperdiet proin fermentum leo vel orci. Ante metus dictum at tempor commodo
ullamcorper a lacus. Risus nec feugiat in fermentum posuere urna. In nisl nisi scelerisque eu ultrices vitae. Fringilla
urna porttitor rhoncus dolor purus. Id leo in vitae turpis massa sed. Viverra aliquet eget sit amet tellus cras
adipiscing. Elementum eu facilisis sed odio morbi quis commodo. Pellentesque elit eget gravida cum sociis natoque
penatibus et magnis. Urna condimentum mattis pellentesque id nibh. Tincidunt id aliquet risus feugiat in. Tortor
posuere ac ut consequat semper viverra nam libero. Tellus pellentesque eu tincidunt tortor aliquam nulla facilisi cras
fermentum. Pharetra magna ac placerat vestibulum lectus.</p>
</div>
</div>
</body>
</html>
.clear {
clear: both;
}
(EDIT: my current code added to bottom of post)
I need to set a value for the height of the div in order for it to hide/scroll overflow properly, but I don't want a div at a specific pixel height. I can solve that by using % or vh units, but I don't actually want to use those units. By that, I mean I don't want my div to always be, for example, 2/3 of the page, because that means the bottom of the div will be a different distance from the bottom of the browser window, like this-
* {
padding: 0;
margin: 0;
}
html, body {
width: 100%;
height: 100%;
}
body > div {
width: 90%;
height: 90%;
background: yellow;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style2.css">
</head>
<body>
<div>
</div>
</body>
</html>
-I want it to be a consistent distance from the bottom of the browser window,
like this-
html, body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
div {
background-color: yellow;
width: 350px;
position: fixed;
left: 10px;
top: 10px;
right: 10px;
bottom: 10px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style2.css">
</head>
<body>
<div>
</div>
</body>
</html>
(for visual representation primarily, I am not really using the code itself as an example)
Basically, I want my div to be a variable height and hide/scroll overflow, but always 10px from the bottom.
I think these describe the same problem I'm having:
Setting a length (height or width) for one element minus the variable length of another, i.e. calc(x - y), where y is unknown
Getting a scrollable child div to Vertically fill the remainder of its parent dynamically
The answers there are to use tables or flexbox - are these the only options (without using javascript)?
My code:
* {
margin: 0;
padding: 0;
}
body {
font-family: Helvetica, Arial, sans-serif;
overflow-x: hidden;
overflow-y: hidden;
width: 100%;
height: 100%;
}
p {
font-size: 9pt;
}
a {
text-decoration: none;
color: black;
}
.container { /*this contains all the divs!!*/
padding: 10px;
}
.header {
}
.name {
float: left;
width: 25vw;
padding-right: 5vw;
}
.about {
width: 65vw;
}
.main { /*this contains divs 'left' and 'right'*/
/*background-color: #CCCCCC;*/
clear: left;
padding-top: 10px;
width: 95vw;
}
.left {
/*background-color: #E6E6E6;*/
float: left;
min-height: 10px;
width: 25vw;
padding-right: 5vw;
}
.hold { /*this is how i tried your solution*/
position: relative;
height: calc(95vh - 10px);
}
.right { /*this is my problem div*/
background-color: #FFFF00;
width: 65vw;
height: 100%;
overflow-y: hidden;
overflow-x: hidden;
}
.lorem {
margin-right: 20vw;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> Name </title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="header">
<div class="name">
<p> Name </p>
</div> <!-- end div name -->
<div class="about">
<p> about </p>
</div> <!-- end div name -->
</div> <!-- end div header -->
<div class="main">
<div class="left">
</div> <!-- end div left -->
<div class="hold">
<div class="right">
<div class="lorem">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam feugiat facilisis purus at fermentum. Etiam ultricies iaculis nulla maximus cursus. Maecenas justo nulla, suscipit a dapibus at, lobortis nec mauris. Mauris egestas mi sit amet risus convallis, in hendrerit lorem maximus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse sollicitudin tempor libero, nec molestie dui tempor sit amet. Aenean molestie ex id nisl venenatis, quis tincidunt lectus porta. Vivamus aliquam lobortis nulla, id porta leo consequat sollicitudin. Ut iaculis neque placerat ipsum placerat tincidunt.
Quisque libero sem, hendrerit quis urna sit amet, mollis venenatis nisl. Morbi vel neque rhoncus, congue purus ac, condimentum nunc. Morbi vestibulum metus nec velit eleifend, ac sodales nulla posuere. Praesent id fermentum massa. Morbi vestibulum lorem nulla, ac vestibulum nunc auctor non. Donec ultricies placerat mauris, at pretium nibh finibus eu. Suspendisse gravida neque nisl, sit amet bibendum ante placerat eget. Sed laoreet suscipit turpis vitae ullamcorper. Mauris quis pharetra eros. Curabitur quis diam non dui elementum facilisis vel ac sem. Duis vitae augue vitae mi pulvinar placerat ut quis purus. Donec sagittis maximus aliquam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
Phasellus pharetra nisi arcu, in laoreet lacus convallis sed. Nam euismod ligula felis, ut laoreet nisl sodales eget. Maecenas cursus, augue vitae suscipit laoreet, purus magna bibendum tellus, sed maximus ex dui ac velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nulla eget aliquet tellus, in viverra sapien. Sed eget urna mauris. Morbi dapibus dolor et felis viverra condimentum sed a nisl. Integer congue cursus ultrices. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse nulla risus, pulvinar eget odio vitae, scelerisque cursus magna. Nam maximus eros vitae massa euismod, vel tempus felis vulputate.
Nunc blandit massa a nisl viverra, vitae molestie ex rhoncus. Pellentesque finibus luctus nisi. Sed quis luctus metus. Nullam sed augue ultrices, lacinia dolor ac, egestas ante. In non nisi nibh. Sed vitae dui libero. Duis ut ullamcorper urna. Phasellus quis fringilla leo.
Nulla porta tellus ut nibh pharetra dapibus. Mauris ullamcorper egestas aliquam. Cras posuere scelerisque imperdiet. In ultrices, leo eu molestie bibendum, augue dui semper ante, vel faucibus nibh enim sed eros. Mauris ipsum dui, placerat et tincidunt vitae, laoreet vel enim. Praesent at ligula et neque placerat blandit sed vulputate ipsum. Phasellus sodales, odio nec aliquam pretium, augue lacus mattis quam, nec vulputate purus lorem vitae nisi.
Suspendisse nisl ipsum, volutpat ac dapibus at, tincidunt eget nulla. Mauris ornare a nisi ac fringilla. Maecenas leo sapien, vulputate in dictum a, feugiat in eros. Aliquam sit amet sagittis leo. Mauris metus nisl, convallis eget mollis ut, ullamcorper eu tellus. Pellentesque eu dolor tempor, bibendum leo vitae, maximus velit. Aenean volutpat neque sit amet tellus mattis euismod.
Quisque nec vehicula orci. Curabitur varius fringilla risus, convallis tincidunt velit porttitor vitae. Aenean in lacus nec nunc tempor dignissim nec pretium sem. Nullam finibus odio quis metus ornare, in fermentum elit rutrum. Proin vitae dui in metus vehicula sodales. Donec massa neque, suscipit ac est quis, ultrices auctor risus. Cras eu auctor lectus. Nam sagittis vulputate hendrerit. Maecenas consequat odio justo, at malesuada nulla ullamcorper a. Donec arcu tellus, dignissim ut velit vel, consequat scelerisque dolor. Curabitur dictum vel risus quis consequat.
Pellentesque fringilla eu nisi sed tincidunt. Nulla feugiat sit amet purus sit amet cursus. Suspendisse nibh purus, tincidunt eu congue ut, ultricies id lectus. Phasellus convallis in nibh vel molestie. Nunc condimentum congue justo. In congue, turpis at vulputate imperdiet, dolor erat ultricies turpis, vitae egestas est augue in nisl. Ut ut leo diam. Duis vulputate ligula velit, vitae volutpat felis viverra a. Maecenas justo quam, lobortis a placerat ut, ullamcorper ac lorem. Sed eu vehicula odio.
Fusce id mauris ornare, mollis mi at, vulputate turpis. Praesent a risus feugiat, rutrum lacus nec, sodales nisi. Nulla ullamcorper libero pretium lacus accumsan, eu tempor mi porta. In tincidunt porta feugiat. Cras lectus arcu, convallis nec neque ac, vestibulum pretium ex. Curabitur mi ipsum, commodo ut eros eget, fringilla fringilla tortor. Curabitur maximus tellus ut turpis malesuada, auctor semper lectus porta. Suspendisse non sapien sagittis, dapibus tellus et, egestas quam. Aliquam vitae massa sit amet urna rhoncus rutrum sit amet et lorem. Phasellus gravida justo ut vulputate vestibulum.
Nunc sed tempus metus, sit amet volutpat mi. Quisque sed metus rutrum, iaculis enim sed, sodales lacus. Quisque quis mi ac sapien scelerisque efficitur lacinia et nunc. Proin tincidunt scelerisque turpis, non euismod ante interdum at. Sed vitae velit scelerisque, placerat nulla in, egestas justo. Mauris urna orci, pulvinar a nibh a, luctus pellentesque mauris. Nulla faucibus hendrerit urna non venenatis. Quisque nulla mi, suscipit sit amet nunc eu, dictum ullamcorper tellus. Donec lacus libero, commodo quis mauris pellentesque, feugiat iaculis nisl. Nulla facilisi. Suspendisse sed risus quis risus fringilla condimentum. Aenean aliquet in eros vel volutpat. Vivamus malesuada ultrices lorem sit amet feugiat. In interdum leo ac orci sollicitudin, maximus vestibulum nisl gravida. Sed venenatis pharetra fringilla. Etiam mauris risus, cursus et est tristique, mattis venenatis nisi.
</p>
</div> <!-- end div LOREM -->
</div> <!-- end div main -->
</div> <!-- end div hold -->
</div> <!-- end div container -->
</body>
</html>
You're on the right track! You can combine vh with calc to get the desired effect.
height: calc(100vh - 10px) - assuming the element is positioned at the top of the screen, that'll achieve the effect you're describing.
To handle scroll/overflow, you'll need an inner container - a div inside the one you set the height property on. Give that inner div { height: 100%; overflow: auto; } and you should be all set.
Here's a demo - to see it working, use the full screen view and shrink your browser's height.
/* These styles are just to make this easier to see,
and to normalize the display a little. */
* { box-sizing: border-box; margin: 0; padding: 0; }
.page { width: 100px; border: 2px solid; }
/* Here's the box that locks to some distance from the bottom, in this case 30px */
.outer {
height: calc(100vh - 30px);
position: relative;
border: 1px solid blue;
}
/* And here's the scrollable container inside it */
.inner {
height: 100%;
overflow: auto;
}
<div class="page">
<div class="outer">
<div class="inner">
content content content content
content content content content
content content content content
</div>
</div>
</div>
I want to create four elements on the left side where the text is out of the view. with hover on one element only this should slide in, but all elements slides in.
I didn't have an idea at this point. Why do all elements slide in?
<div class="fixed-icons">
<div class="fixed-icons__item fixed-icons__item--booking">
<span>booking</span>
</div>
<div class="fixed-icons__item fixed-icons__item--voucher">
<span>voucher</span>
</div>
<div class="fixed-icons__item fixed-icons__item--phone">
<span>phone</span>
</div>
<div class="fixed-icons__item fixed-icons__item--eye">
<span>eye</span>
</div>
</div>
SCSS
.fixed-icons {
position: fixed;
top:40%;
right:0;
.fixed-icons__item {
border: 1px solid white;
background-color: #004576;
color: white;
padding: 0.25rem;
margin: 0.25rem;
cursor: pointer;
margin-right:-50px;
transition: 1s;
&:hover {
transition: 1s;
margin-right:0;
}
}
}
codepen demo
Here's the solution.
Animating the margin property caused some weird results - replaced it with transform.
.fixed-icons {
position: fixed;
top:40%;
right:0;
.fixed-icons__item {
border: 1px solid white;
background-color: #004576;
color: white;
padding: 0.25rem;
margin: 0.25rem;
cursor: pointer;
margin-right:-50px;
transition: 1s;
&:hover {
transition: 1s;
transform: translateX(-49px);
}
}
}
Here's the solution.
Animating the `margin` property caused some weird results - replaced it with `transform`.
<div class="fixed-icons">
<div class="fixed-icons__item fixed-icons__item--booking">
<span>booking</span>
</div>
<div class="fixed-icons__item fixed-icons__item--voucher">
<span>voucher</span>
</div>
<div class="fixed-icons__item fixed-icons__item--phone">
<span>phone</span>
</div>
<div class="fixed-icons__item fixed-icons__item--eye">
<span>eye</span>
</div>
</div>
Codepen Link
try this, i have edited your css
.fixed-icons {
position: fixed;
top: 40%;
right: 0;
}
.fixed-icons .fixed-icons__item {
border: 1px solid white;
background-color: #004576;
color: white;
padding: 0.25rem;
margin: 0.25rem;
cursor: pointer;
margin-right: -50px;
transition: 1s;
}
.fixed-icons .fixed-icons__item:hover {
transition: 1s;
transform: translateX(-49px);
}
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Create a New Pen</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="fixed-icons">
<div class="fixed-icons__item fixed-icons__item--booking">
<span>booking</span>
</div>
<div class="fixed-icons__item fixed-icons__item--voucher">
<span>voucher</span>
</div>
<div class="fixed-icons__item fixed-icons__item--phone">
<span>phone</span>
</div>
<div class="fixed-icons__item fixed-icons__item--eye">
<span>eye</span>
</div>
</div>
</body>
</html>
try this, i dint understand your question exactly but as i understood i have done this, try this may be this will help you out
#import url(http://weloveiconfonts.com/api/?family=entypo);
/* entypo */
[class*="entypo-"]:before {
font-family: "entypo", sans-serif;
}
a {
text-decoration: none;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
.container {
margin: 0 auto;
padding: 20px 50px;
background:white;
}
#sticky-social {
left: 0;
position: fixed;
top: 50px;
}
#sticky-social a {
background: #333;
color: #fff;
display: block;
height: 35px;
font: 16px "Open Sans", sans-serif;
line-height: 35px;
position: relative;
text-align: center;
width: 35px;
}
#sticky-social a:hover span {
left: 100%;
}
#sticky-social a span {
line-height: 35px;
left: -120px;
position: absolute;
text-align:center;
width:120px;
}
#sticky-social a[class*="facebook"],
#sticky-social a[class*="facebook"]:hover,
#sticky-social a[class*="facebook"] span { background: #3b5998; }
#sticky-social a[class*="twitter"],
#sticky-social a[class*="twitter"]:hover,
#sticky-social a[class*="twitter"] span { background: #00aced; }
#sticky-social a[class*="gplus"],
#sticky-social a[class*="gplus"]:hover,
#sticky-social a[class*="gplus"] span { background: #dd4b39; }
#sticky-social a[class*="linkedin"],
#sticky-social a[class*="linkedin"]:hover,
#sticky-social a[class*="linkedin"] span { background: #007bb6; }
#sticky-social a[class*="instagrem"],
#sticky-social a[class*="instagrem"]:hover,
#sticky-social a[class*="instagrem"] span { background: #517fa4; }
#sticky-social a[class*="stumbleupon"],
#sticky-social a[class*="stumbleupon"]:hover,
#sticky-social a[class*="stumbleupon"] span { background: #eb4924; }
#sticky-social a[class*="pinterest"],
#sticky-social a[class*="pinterest"]:hover,
#sticky-social a[class*="pinterest"] span { background: #cc2127; }
#sticky-social a[class*="flickr"],
#sticky-social a[class*="flickr"]:hover,
#sticky-social a[class*="flickr"] span { background: #ff0084; }
#sticky-social a[class*="tumblr"],
#sticky-social a[class*="tumblr"]:hover,
#sticky-social a[class*="tumblr"] span { background: #32506d; }
<div class="container">
<h1>Social Sidebar</h1>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.</p>
<p>Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus.</p>
<p>Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna.</p>
<p>Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum.</p>
<p>Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac</p>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium.</p>
<p>Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus.</p>
<p>Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna.</p>
<p>Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia. Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum.</p>
<p>Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi. Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac</p>
</div>
<aside id="sticky-social">
<ul>
<li><span>Facebook</span></li>
<li><span>Twitter</span></li>
<li><span>Google+</span></li>
<li><span>LinkedIn</span></li>
<li><span>Instagram</span></li>
<li><span>StumbleUpon</span></li>
<li><span>Pinterest</span></li>
<li><span>Flickr</span></li>
<li><span>Tumblr</span></li>
</ul>
</aside>
the direction of container causes this problem and you must set width length for the items.
try this code:
.fixed-icons {
position: fixed;
top:40%;
right:0;
.fixed-icons__item {
border: 1px solid white;
background-color: #004576;
color: white;
padding: 0.25rem;
margin: 0.25rem;
cursor: pointer;
margin-right:-50px;
transition: 1s;
width:80px;
&:hover {
transition: 1s;
margin-right:0;
}
}
}
<div style="direction:rtl;">
<div class="fixed-icons">
<div class="fixed-icons__item fixed-icons__item--booking">
<span>booking</span>
</div>
<div class="fixed-icons__item fixed-icons__item--voucher">
<span>voucher</span>
</div>
<div class="fixed-icons__item fixed-icons__item--phone">
<span>phone</span>
</div>
<div class="fixed-icons__item fixed-icons__item--eye">
<span>eye</span>
</div>
</div>
</div>
I've got a problem with my website where Im using transform: translate(-50%,-50%); to fix my webpage not being in the middle of the page but slightly off the middle. Now ive got a problem : I cant scroll!
Example of a working webpage and a bad one:
As you can see the text is overflowing the page. How am I able to fix this?
Full CSS code of 'innerlayer'
.innerlayer {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
transform-origin: 0 0;
background-color: dodgerblue;
box-shadow: 10px 10px 40px #6680ed;
min-width: 50%;
max-width: 50%;
border: 1px solid black;
}
html {
padding: 0;
}
body {
background-color: cornflowerblue;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
}
.contentlayer {
text-align: center;
}
.innerlayer {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%,-50%);
transform-origin: 0 0;
background-color: dodgerblue;
box-shadow: 10px 10px 40px #6680ed;
min-width: 50%;
max-width: 50%;
border: 1px solid black;
}
.header {
font-weight: bolder;
font-family: Calibri;
font-size: 30pt;
border-bottom: 1px solid black;
}
.navigation {
border-bottom: 1px solid black;
background-color: #6499f1;
}
ul {
list-style: none;
margin: 0;
padding: 10 0;
}
li {
background-color: #6499f1;
border-left: 1px solid black;
padding: 10 10;
margin-right: -4px;
font-family: Arial;
font-weight: bold;
text-decoration: none;
display: inline;
}
li:last-child {
border-right: 1px solid black;
}
li:hover {
background-color: #6490e8;
}
.body {
font-family: Arial;
}
.bodytitle {
font-weight: bolder;
font-family: Calibri;
font-size: 15pt;
padding: 5 0;
}
.bodytext {
padding: 5 5;
}
.border-bottom {
border-bottom: 1px solid black;
}
.border-top {
border-top: 1px solid black;
}
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/style.css">
<script src="css/jquery-3.1.1.min.js"></script>
<title>Title</title>
</head>
<body id="body">
<div class="outerlayer" id="outerlayer">
<div class="innerlayer" id="innerlayer">
<div class="contentlayer">
<div class="header">
<?php echo $obj1[0]['name'] . " [" . $_GET['id'] . "]"; ?>
</div>
<div class="navigation">
<ul>
<li>Information</li>
<li>Statistics</li>
<li>Back</li>
</ul>
</div>
<div class="body">
<div class="bodytitle border-bottom">
Background Introduction
</div>
<div class="bodytext">
</div>
<div class="bodytitle border-bottom border-top">
Economy - overview
</div>
<div class="bodytext">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam luctus facilisis sollicitudin. Donec consectetur consectetur libero sed gravida. Nulla sit amet vehicula felis. In dapibus dui odio, id venenatis ante sollicitudin at. Aenean molestie lectus leo, in egestas mi tristique sit amet. Integer faucibus feugiat feugiat. Vestibulum ac porttitor dolor.
Vestibulum consectetur ornare magna, id suscipit lectus posuere ut. In dictum ornare fringilla. Quisque convallis ac libero vel vulputate. In hendrerit dolor id dapibus auctor. Donec ac nisl quis nulla volutpat condimentum ac eu velit. Nullam pretium neque tempor luctus pretium. Fusce quis diam sollicitudin, vestibulum sapien vitae, faucibus risus. Vestibulum tincidunt libero nec auctor maximus. Sed ultrices sem at nunc condimentum egestas. Praesent eu enim bibendum, consequat neque sed, sollicitudin diam. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Vestibulum eget maximus leo, eu feugiat purus. Nullam semper mauris id erat rhoncus malesuada. Cras nulla diam, euismod id purus eget, ultrices efficitur velit. Donec elementum auctor ex. Nunc condimentum placerat ex eget maximus.
Quisque dignissim, erat non lobortis egestas, enim justo cursus lectus, ac semper felis diam et eros. Sed scelerisque, nulla at vehicula ullamcorper, sem est pretium nisi, in consequat sapien lorem id erat. Aenean et dolor eget velit consectetur venenatis vel sit amet tellus. Fusce in venenatis nibh, vel euismod magna. Nunc sed libero vitae urna ullamcorper iaculis. Donec massa ipsum, mattis eu sollicitudin eu, porta non arcu. In porttitor turpis at purus aliquet consequat. Aliquam massa orci, tempus et suscipit et, tincidunt eu leo. Curabitur porta felis nunc, nec porttitor arcu mollis rhoncus. Vivamus vel sapien eleifend, hendrerit diam non, feugiat orci.
Nam consectetur ante ac consectetur eleifend. Vestibulum porta, tellus ut fermentum auctor, leo orci tincidunt metus, vitae tincidunt diam ex at quam. Integer nec placerat libero. Maecenas metus est, convallis a bibendum eget, dictum sit amet nunc. Nam ut nibh blandit, porta risus dapibus, imperdiet dolor. Donec viverra lectus non eros porttitor, non eleifend est ullamcorper. Etiam sed metus in nunc mollis hendrerit. Cras nec felis purus. Morbi nec posuere velit. Vivamus interdum convallis odio, sit amet tempor eros tempor non. Praesent vulputate mi sit amet nibh convallis luctus. Suspendisse vitae nisl vitae mauris scelerisque dictum in ut libero. Nam rutrum justo ex, id luctus risus laoreet vel. Aliquam non pulvinar orci, non maximus massa. Nulla condimentum orci sollicitudin libero faucibus, in rutrum neque suscipit.
Vestibulum aliquet ornare libero, ac luctus enim cursus ut. In scelerisque feugiat felis at viverra. Nam quis neque vestibulum, accumsan lorem nec, faucibus ligula. Sed feugiat quam ex, non commodo felis rutrum in. Nunc aliquet turpis in diam efficitur, vitae bibendum sapien dictum. Cras a pulvinar enim, hendrerit consequat erat. Pellentesque viverra viverra lorem, nec mattis eros dictum sed. Proin ut metus augue. Proin quis fermentum urna. Vestibulum lobortis augue a sapien iaculis, vitae vehicula magna pharetra. In suscipit ex ipsum. Aenean id efficitur massa. Vestibulum varius consectetur purus, ac ultricies leo scelerisque quis. Duis urna nisi, vehicula semper nulla nec, pellentesque dignissim nibh.
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Add this class to your css file and the scroll bar with be shown on that div but if you want to add scroll bar on whole page like a normal page then you have to translate the div as body but try to add this css code to the css file and hope it works:
.innerlayer {
height: 100%;
overflow-y: scroll;
}