Just trying to figure out the layout to make this work. I have to show and hide a menu when you click on the arrow shape at the bottom of the icon panel and then show the panel when i click the same shape again. The part that is troubling me is how to shape the arrow container, should i use css3 shapes or just a backgound img for that part (which seems unlikely to me since it have to fit perfectly with the icons container) or just make the whole thing (tne container and the bottom shape a css3 shape).
I know how to make the toggle up / down work but just trying to layout this the best way possible, any ideas will be really appreciated. I can use css3 shapes, flex, etc, crossbrowsing is not an issue for this one.
Here's the images:
Here's the html that i have so far:
<nav class="l-apps l-container">
<ul>
<li>
<img src="assets/img/icons/google.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/word.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/file.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/network.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/powerpoint.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/diamond.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/other.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/pencil.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/excel.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/triangle.png">
Lorem Ipsum
</li>
</ul>
</nav>
Well i figure it out in case somebody else needs to do this someday:
Basically same html but adding some containers for the css3 shaped div with the toggle trigger:
<nav class="l-apps l-container">
<ul>
<li>
<img src="assets/img/icons/google.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/word.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/file.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/network.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/powerpoint.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/diamond.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/other.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/pencil.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/excel.png">
Lorem Ipsum
</li>
<li>
<img src="assets/img/icons/triangle.png">
Lorem Ipsum
</li>
</ul>
<div class="shape-container">
<div class="base">
<i class="icon-toogle fa fa-angle-double-up"></i>
</div>
</div>
</nav>
Then this is the scss for the shape:
.base {
background: $blue;
display: inline-block;
height: 105px;
margin-top: 50px;
position: relative;
width: 150px;
.icon-toogle {
position:absolute;
color: $white;
font-size:1.8em;
bottom:-.35em;
left:0;
right:0;
margin:auto;
text-align:center;
}
&:before {
border-top: 20px solid $blue;
border-left: 75px solid transparent;
border-right: 75px solid transparent;
content: "";
height: 0;
left: 0;
position: absolute;
bottom: -20px;
width: 0;
}
}
Now i have other problem, the whole shape have a pattern background image (the icon container and the css shape at the bottom), i can't get to put a background image to the shape, maybe because i use borders to make the css shape. Is there a way to put a background image on the shape ?
my idea is
$('div').on('click', function(){
var _class = $(this).hasClass('a-top') ? 'b-top' : 'a-top';
$(this).attr('class',_class);
});
.a-top {
background: #f00;
height: 50px;
top:0px;
transition: all .3s ease-out;
}
.b-top {
background: #f00;
height: 100px;
transition: all .3s ease-out;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="a-top">
menu click me.
</div>
Related
I am building a message box with title, description, and answers.
I have been struggling for days with that, even played with a Codepen, but can't figure to handle this correctly.
I need:
Title to expand to a maximum of 300px before scrolling
Description to expand to a maximum to left space if no answer (or few), distribute space say 80% of space otherwise (I will add a button to hide this space) before scrolling also
Fixed height for message number title
Messages div to expand to a maximum space left
Input area to stay at bottom and able to size up if any user input (again let's say 20% before scrolling?)
Codepen link
<div class="demoContainer">
<div class="page">
<div class="title">
<h1>My awesome title that is so long i will move everything down</h1>
<button>Some stuff to click</button>
</div>
<div class="row">
<div class="colLeft">
<div class="description">
<h2>Author</h2>
<p>lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsumipsum lorem ipsum lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsumipsum lorem ipsum lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsumipsum lorem ipsum lorem ipsum lorem ipsumlorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum </p>
</div>
<div class="between">
<p>Answers</p>
</div>
<div class="messages">
<ul>
<li>
toto
</li>
<li>
tAta
</li>
<li>
tAta
tAta
</li>
<li>
tAta
</li>
<li>
tAta
</li>
<li>
tAta
</li>
>
<li>
tAta
</li>
>
<li>
tAta
</li>
>
<li>
tAta
</li>
>
<li>
tAta
</li>
</ul>
</div>
<div class="input">
<textarea placeholder="Input height adapt to size until a maximum"></textarea>
</div>
</div>
<div class="colRight">
<ul>
<li>
some
</li>
<li>
stuff
</li>
</ul>
</div>
</div>
</div>
<div class="divider"></div>
<div class="page">
<div class="title">
<h1>My awesome short title</h1>
<button>Some stuff to click</button>
</div>
<div class="row">
<div class="colLeft">
<div class="description">
<h2>Author</h2>
<p>lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum lorem ipsum </p>
</div>
<div class="between">
<p>Answers</p>
</div>
<div class="messages">
<ul>
<li>
toto
</li>
<li>
tAta
</li>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</ul>
</div>
<div class="input">
<textarea placeholder="Input height adapt to size until a maximum"></textarea>
</div>
</div>
<div class="colRight">
<ul>
<li>
some
</li>
<li>
stuff
</li>
</ul>
</div>
</div>
</div>
</div>
* {
box-sizing: border-box;
}
.demoContainer {
display: flex;
flex-direction: row;
}
.divider {
width: 8px;
}
.page {
height: 600px;
width: 550px;
background-color: lightgrey;
display: flex;
flex-direction: column;
overflow: auto;
}
.title {
display: inline-flex;
justify-content: space-between;
align-items: center;
max-height: 200px;
}
.title button {
width: 90px;
height: 30px;
}
.row {
display: flex;
/*flex: 1 1 100%;*/
min-height: 0;
height: 100%;
}
.colLeft {
flex: 3 1 auto;
min-height: 0;
height: 100%;
border: 1px solid blue;
display: block;
flex-direction: column;
position: relative;
/*align-items: stretch;
align-content: stretch;*/
}
.description {
border: 1px dashed black;
/*flex: 4 1 100%;*/
max-height: 60%;
overflow: scroll;
}
.between {
border: 1px solid green;
height: 1, 1em;
}
.between>p {
margin: 0;
}
.messages {
border: 1px dashed red;
/*flex: 2 100 auto;*/
overflow: scroll;
}
ul {
max-width: 100%;
}
.input {
width: 100%;
min-height: 1rem;
flex: 1 1 3rem;
display: flex;
border: 1px solid yellow;
position: relative;
bottom: 0;
}
.input>textarea {
width: 100%;
}
.colRight {
flex: 1 1 auto;
border: 1px solid black;
min-width: 150px;
overflow: scroll;
}
The one on the right is a short example of what I would like, but remove <br/> to see the problem.
I tried with display: grid, isplay: block display: flex. I can't seem to find anything satisfying my needs.
My question is: is that even possible? With CSS only?
For everyone wondering, i discovered a few things while digging into css.
First of all is you can set a 100% height on a div to take up the free space if another element is in, but if and only if you set the parent element display: flex; !
With that in mind, it comes easier.
After that, I decided to dive into JS as my problem does not seem to be solvable with CSS only.
I took advantage of the "new" position: sticky; property, and my JS can take care of position it top: 0; or bottom: 0; depending on the scrolling position.
CSS Added :
.stickyBottom{
position: sticky;
bottom: 0;
}
.stickyTop{
position: sticky;
top: 0;
}
JS Code added:
var colLeft = document.getElementsByClassName("messagesInput")[0];
colLeft.onscroll = function(){myFunction()};
// Get the navbar
var between = document.getElementsByClassName("between")[0];
var desc = document.getElementsByClassName("description")[0];
// Get the offset position of the navbar
var sticky = between.offsetTop;
//between.classList.remove("stickyBottom")
function myFunction() {
if (colLeft.scrollTop >= sticky) {
between.classList.remove("stickyBottom")
between.classList.add("stickyTop")
} else {
between.classList.add("stickyBottom")
between.classList.remove("stickyTop");
}
}
It ends up in a way better UX than I initially wanted ! :)
CodePen Link updated accordingly.
Scenario: When I click on the title1 link in the fixed header, it should display title1 section and when I click on title2 link it should display title 2 section on the top like that..but here it's displaying on the top of the page but behind the header, so it's not visible
I have attached the code which I tried, Please help to resolve this
.menu {
height: 165px;
position: fixed;
background-color: lightgrey;
margin-top: -113px;
width: 1090px;
}
#menu-center ul {
margin:35px 0 0px 115px
}
#menu-center ul li {
list-style: none;
margin: 0 30px 0 0;
display: inline;
}
.Avatar1{
background: #ED7D31;
border-radius:50%;
display:inline-block;
padding:10px;
}
.Avatar2{
background: #A5A5A5;
border-radius:50%;
display:inline-block;
padding:10px;
}
.Avatar3{
background: #FFC000;
border-radius:50%;
display:inline-block;
padding:10px;
}
.Avatar4{
background: #5b9bd5;
border-radius:50%;
display:inline-block;
padding:10px;
}
.Avatar5{
background: #70AD47;
border-radius:50%;
display:inline-block;
padding:10px;
}
div.item {
vertical-align: top;
display: inline-block;
text-align: center;
width: 120px;
}
.caption {
display: block;
color:#ffffff;
}
#Title1 {
height: 100%;
width: 100%;
padding-top: 165px;
}
#Title2 {
height: 100%;
width: 100%;
padding-top: 25px;
}
#Title3{
height: 100%;
width: 100%;
padding-top: 25px;
}
#Title4 {
height: 100%;
width: 100%;
padding-top: 25px;
}
#Title5 {
height: 100%;
width: 100%;
padding-top: 280px;
}
.vertical {
border-left: 190px solid #5786c5;
margin-left:900px;
margin-top: -1620px;
height: 1620px;
}
.items-01{
margin-right: 253px;
font-size: 16px;
line-height:1.8;
}
<body>
<table width="1094px" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td>
<div>
<h2 style="
font-size: 28px;
text-align: center;
margin-left: -150px;">Heading</h2>
<div class="m1 menu">
<div id="menu-center">
<ul>
<li><a class="nav-link" href="#Title1"><div class="item"><img src="picture.png" class="Avatar1" width="50" height="50" > <span class="caption">Title1</span></div></a>
</li>
<li><a class="nav-link" href="#Title2"><div class="item"><img src="picture.png" class="Avatar2" width="50" height="50" > <span class="caption">Title2</span></div></a>
</li>
<li><a class="nav-link" href="#Title3"><div class="item"><img src="picture.png" class="Avatar3" width="50" height="50" > <span class="caption">Title3</span></div></a>
</li>
<li><a class="nav-link" href="#Title4"><div class="item"><img src="picture.png" class="Avatar4" width="50" height="50" > <span class="caption">Title4</span></div></a>
</li>
</li>
<li><a class="nav-link" href="#objective"><div class="item"><img src="picture.png" class="Avatar5" width="50" height="50" > <span class="caption">Title5</span></div></a>
</li>
</ul>
</div>
</div>
<div style="margin-top:0px;">
<div class="content" id="Title1">
<h1 style = "color: #333333;font-weight: bold;font-size: 25px;">
Title1
</h1>
<ul>
<li class="items-01">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s
</li>
</ul>
</div>
<div class="content" id="Title2" style="margin-top:0px;">
<h1 style = "color: #333333;font-weight: bold;font-size: 25px;">
Title2
</h1>
<ul>
<li class="items-01">Lorem Ipsum is simply dummy text of the printing
</li>
</ul>
</div>
<div class="content" id="Title3" style="margin-top:0px;">
<h1 style = "color: #333333;font-weight: bold;font-size: 25px;">
Title3
</h1>
<ul>
<li class="items-01">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type.
</li>
</ul>
</div>
<div class="content" id="Title4" style="margin-top:0px;">
<h1 style = "color: #333333;font-weight: bold;font-size: 25px;">
Title4
</h1>
<ul>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
</ul>
</div>
<div class="content" id="Title5" style="margin-top:0px;" >
<h1 style = "color: #333333;font-weight: bold;font-size: 25px;">
Title5
</h1>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.<br/><br/>
when an unknown printer took a galley of type and scrambled it to make a type specimen book</p>
<ul>
<li class="items-01">Lorem Ipsum is simply dummy text </li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
<li class="items-01">Lorem Ipsum is simply dummy text</li>
</ul>
</div>
</div>
</div>
</td>
</tr>
</table>
</body>
It can be achieved by using javascript and jquery library.
Import jquery library to your code.
use this below code inside a script tag.
$('#menu-center ul').find('a').click(function(e){
e.preventDefault();
var menuHeight = $('.menu').height();
var $href = $(this).attr('href');
var $anchor = $($href).offset(); // Get position of section.
//Scroll particular section to top with adjusting menu height.
window.scrollTo($anchor.left,$anchor.top- menuHeight);
return false;
});
I have 3 divs (example below):
<ul>
<div class="parent">
<li>
<div>
Lorem Ipsum is simply dummy
</div>
</li>
</div>
<li>
<div class="parent">
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting
</div>
</li>
</div>
</div>
</ul>
And I want to all of them to have the same widths as the longest. The width of the longest should be the same as the text inside it plus some pixel (f.e. + 15px). The text will be changing so width should dynamically changing. Display has to be inline-table.
Is it possible to do something like that in the HTML/CSS?
Yes it is possible using HTML/CSS. Here is the code snippet.
.parent {
display: inline-block;
width: auto;
}
.parent div {
border: 1px solid black;
padding-right: 15px;
}
<div class="parent">
<div>
Lorem Ipsum is simply dummy
</div>
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting
</div>
<div>
Lorem Ipsum is simply dummy text of the print
</div>
</div>
As per below code...
ul {
display: inline-block;
}
ul li {
list-style: none;
}
li div {
border: 1px solid black;
padding-right: 15px;
}
I am using Bootstrap3 for my responsive page design here. I am adding a box inside the banner content with some text inside it as follows:
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<div class="row">
<section id="slider">
<ul class="rslides" id="modest-slider">
<li class="slider-wrapper">
<div class="slider-img-container">
<img src="http://placehold.it/350x150&text=slider1" alt="slider1" />
</div>
<div class="slider-caption container">
<div class="col-md-7" style="border-left-width: 4px; top: auto; bottom: 126px; width: 600px; background: rgba(255, 255, 255, 0.6); height:130px;">
<h1>Exclusively New Concept!</h1>
<p class="slider-description2">
Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample...
</p>
</div>
</div>
<!-- /.slider-caption -->
</li>
<!-- /.slider-wrapper -->
</ui>
</section>
It is working fine in full screen. When I am resizing the browser the alignment is not working correctly. The box with content is not fit with the page. Any help will be appreciated!!
Try the solution with minor changes
Demo http://www.bootply.com/p6wIuR17QB
/* CSS used here will be applied after bootstrap.css */
#modest-slider {
position: relative;
}
.slider-caption {
position: absolute;
bottom: 0;
margin-bottom: 20px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"/>
<section id="slider">
<ul class="rslides list-unstyled" id="modest-slider" stye="position:relative;">
<li class="slider-wrapper">
<div class="slider-img-container">
<img src="http://placehold.it/600x300&text=slider1" alt="slider1" class="img-responsive">
</div>
<div class="slider-caption container">
<div class="col-xs-10 col-sm-8" style="background: rgba(255, 255, 255, 0.6);">
<h1>Exclusively New Concept!</h1>
<p class="slider-description2">
Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample...
</p>
</div>
</div>
<!-- /.slider-caption -->
</li>
<!-- /.slider-wrapper -->
</ul>
</section>
Try this:
<div class="row" >
<!-- changing width to 100% with 600px maximum -->
<div class="col-md-7" style="border-left-width: 4px; top: auto; bottom: 126px; width: 100%; max-width: 600px; background: rgba(255, 255, 255, 0.6); height:130px;">
<h1>Exclusively New Concept!</h1>
<p class="slider-description2">
Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample Lorem ipsum sample...
</p>
</div>
This will not make the height change though, for that try:
change "height:130px;" to "height: 100%; max-height: 130px;"
You really need to read more about how Bootstrap works though as this is not a good way to use it
First, you should not assign width to your div, in case you are using bootstrap.
<div class="col-md-7" style="...width: 600px...
Using class col-md-7 assign a particular width to your section, which is in %, so that when you resize your browser, the div resizes accordingly.
But, you overwrote the width with 600px, which is a fixed width and does not flex with browser resize.
I've just added one small area on my website which looks like this:
The problem is in the "About me:" section. I need to move text there to look like this:
Can anyone suggest css / html align solution that would position text like in the second example?
Current HTML
<div id="profInfo">
<div id="profImage">
<img src="..." alt="user: ..."/>
</div>
<div id="profDetails">
<ul>
<li><b class="underb" style="color: #7da315;">Name</b><b style="color: #7da315;">:</b> Ilya Knaup </li>
<li><b class="underb" style="color: #1e8bb4;">Country</b><b style="color: #1e8bb4;">:</b> Spain </li>
<li><b class="underb" style="color: #c86c1f;">Stories</b><b style="color: #c86c1f;">:</b></li>
<li><b class="underb" style="color: #af1e83;">About me</b><b style="color: #af1e83;">:</b> Lorem ipsum dummy textum ...</li>
</ul>
</div>
</div>
Current CSS
* {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
#profInfo {
width: 512px;
margin: 10px 4px 0 3px;
}
#profImage {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
height: 100px;
width: 100px;
padding: 1px;
float: left;
background: #535353;
border: 1px solid #272727;
-khtml--webkit-box-shadow: 0 1px 2px #d6d6d6;
-moz-box-shadow: 0 1px 2px #d6d6d6;
box-shadow: 0 1px 2px #d6d6d6;
}
#profDetails {
float: right;
width: 395px;
line-height: 22px;
}
#profDetails ul {
list-style: none;
font-size: 13px;
}
.underb {
text-decoration: underline;
}
#profImage img {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
Here is all code together http://jsfiddle.net/8ERvz/7/
You can use float:left (on the “About Me”) and overflow:hidden (on the rest of the text) to achieve the layout you want.
Here’s an implementation with <span> tags and style attributes, just to illustrate what’s going on:
<li>
<span style="float: left;">
<b class="underb" style="color: #af1e83;">About me</b>
<b style="color: #af1e83;">:</b>
</span>
<span style="display:block; overflow:hidden; padding-left:.5em;">
Lorem ipsum dummy textum Lorem ipsum dummy textum Lorem ipsum dummy textum Lorem ipsum dummy textumLorem ipsum dummy textum Lorem ipsum dummy textum Lorem ipsum dummy textum Lorem ipsum dummy textum Lorem ipsum dummy textum
</span>
</li>
http://jsfiddle.net/fpzkx/
My answer to this question used the same technique; reading that might make it a bit clearer.
As crazy as it sounds, you can use a table.
You've got a set of headers with a set of data. Sounds like a table to me.
Update HTML
<div id="profInfo">
<div id="profImage">
<img src="..." alt="user: ..."/>
</div>
<div id="profDetails">
<ul>
<li><b class="underb" style="color: #7da315;">Name</b><b style="color: #7da315;">:</b> Ilya Knaup </li>
<li><b class="underb" style="color: #1e8bb4;">Country</b><b style="color: #1e8bb4;">:</b> Spain </li>
<li><b class="underb" style="color: #c86c1f;">Stories</b><b style="color: #c86c1f;">:</b></li>
<li><div style="float:left; display:block;width:60px;"><b class="underb" style="color: #af1e83;">About me</b>: </div> <p style="display:block;width:300px;padding-left:60px;">Lorem ipsum dummy textum ... Lorem ipsum dummy textum ... Lorem ipsum dummy textum ... Lorem ipsum dummy textum ...<p></li>
</ul>
</div>
</div>
Of course it would be better to store these updates in your stylesheet as opposed to inline styles but this will show you what needs to be done.