If we add direction: rtl; in CSS then word-wrap and word-break styles are not working. How we can solve this issue in Pure CSS?
Note: I need to support browsers IE9+ and chrome
#container {
height: 440px;
width: 150px;
left: 40%;
top: 20%;
border: 2px solid green;
margin: 0 auto;
}
#leftDiv{
width: 70px;
float: left;
word-wrap: break-word;
overflow: hidden;
line-height: 20px;
height: 20px;
}
#centreDiv{
width: 10px;
float: left;
}
#rightDiv{
//word-wrap: break-word;
width: 70px;
float: right;
direction: rtl;
overflow: hidden;
line-height: 20px;
height: 20px;
}
<div id="container">
<div id='leftDiv'>
Java121HTML121HTML121Javscript121
</div>
<div id='centreDiv'>
...
</div>
<div id='dummy'>
<div id='rightDiv'>
Java121HTML121HTML121Javscript121
</div>
</div>
If you uncomment right div word break will change
It seems to be working, below is the running code and attached screenshot.
div{
direction: rtl;
max-width: 600px;
border: 1px solid black;
word-wrap: break-word;
}
<div>
<h1>Lorem ipsum dolor sit amet, consecteturasdasdasdasdasdasdasdasdasdasdasdasdasdasd adipiscing elit. Quisque sagittis consequat augue, eget euismod quam ultricies at. Donec venenatis, turpis.</h1>
</div>
Related
The following code snippet displays some headlines, with some icons floated on the left. The parent div has a defined height, with scroll:auto set.
Currently, scrolling to the bottom looks like this:
However, I'd like to clip off the icons when the text entries end, so when scrolling to the bottom, it looks like this:
The reason for the use of float is so that when there are not many icons, the text flows like this:
.parent {
position: absolute;
height: 100px;
width: 400px;
overflow: scroll;
}
.content {
background-color: cyan;
padding: 6px;
}
.icon {
float: left;
clear: both;
background-color: lightpink;
width: 38px;
height: 38px;
margin-right: 8px;
margin-bottom: 6px;
}
.entry {
font-size: 18px;
}
<div class="parent">
<div class="content">
<img class="icon">
<img class="icon">
<img class="icon">
<img class="icon">
<div class="entry">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div class="entry">Quisque eleifend viverra risus, nec maximus nisi vestibulum eu</div>
<div class="entry">Mauris in libero lacus</div>
</div>
</div>
Just smack a overflow: clip on your .content along with the sexy overflow-clip-margin: content-box.
Note on overflow-clip-margin: Safari doesn't support it (yet). Quick edit: Firefox has some issues with overflow-clip-margin's visual-box property too. My bad!
Without it, the images are still clipped but without caring about your .content padding. Shouldn't be an issue if your text isn't actually behind a cyan background-color; it's hard to tell on a white background.
.parent {
position: absolute;
height: 100px;
width: 400px;
overflow: scroll;
}
.content {
background-color: cyan;
padding: 6px;
overflow: clip;
overflow-clip-margin: content-box;
}
.icon {
float: left;
clear: both;
background-color: lightpink;
width: 38px;
height: 38px;
margin-right: 8px;
margin-bottom: 6px;
}
.entry {
font-size: 18px;
}
<div class="parent">
<div class="content">
<img class="icon">
<img class="icon">
<img class="icon">
<img class="icon">
<div class="entry">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div class="entry">Quisque eleifend viverra risus, nec maximus nisi vestibulum eu</div>
<div class="entry">Mauris in libero lacus</div>
</div>
</div>
.parent {
position: absolute;
height: 100px;
width: 400px;
overflow: scroll;
}
.content {
background-color: cyan;
padding: 6px 6px 0 6px;
overflow: hidden;
position: relative;
border-bottom: 8px solid cyan; /* same color */
}
.icons,
.entries {
display: flex;
flex-direction: column;
}
.icons {
position: absolute;
top: 8px;
left: 8px;
}
.entries {
margin-left: 56px; /* icon width '38' + icon left '8' and right '8' distance */
}
.icon {
background-color: lightpink;
width: 38px;
height: 38px;
margin-bottom: 6px;
}
.entry {
font-size: 18px;
}
<div class="parent">
<div class="content">
<div class="icons">
<img class="icon">
<img class="icon">
<img class="icon">
<img class="icon">
</div>
<div class="entries">
<div class="entry">Lorem ipsum dolor sit amet, consectetur adipiscing elit</div>
<div class="entry">Quisque eleifend viverra risus, nec maximus nisi vestibulum eu</div>
<div class="entry">Mauris in libero lacus</div>
</div>
</div>
</div>
I have an html5 video tag with a div that has a text caption overlayed and when you scroll in chrome, the text div disappears as it gets near the top or bottom of the screen fold. Sometimes it's as its nearing the top of the screen, sometimes the bottom. I think it depends where the video is on the screen when it's refreshed.
Anyone know what is causing this? I think this is pretty barebones markup.
codepen: https://codepen.io/sharpdesigner/pen/KRgQZZ
screen capture of the issue: https://imgur.com/a/Hn8DWkP
html
<section id="video-landing" class="hide-mobile">
<div class="container">
<div class="row">
<div class="col-md-6 video-caption">
<h1>Lorem ipsum dolor sit</h1>
<p class="big">Quisque varius erat et</p>
<p>Vivamus aliquam lectus est. Nulla vitae fringilla felis. Aenean id elit sit amet sem mattis bibendum eu a felis. Interdum et malesuada fames ac ante ipsum primis in faucibus.</p>
</div>
</div>
</div> <!-- /container -->
<video muted autoplay="autoplay" loop="loop" id="bgvid">
<source src="http://www.mysportresume.com/phone.mp4" type="video/mp4" />
</video>
</section><!-- #section -->
css
body {
height: 2000px;
margin-top: 500px;
}
.container {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}
section#video-landing, section#video-landing-mobile {
background: url('../images/video-bg.jpg') no-repeat 0 -175px;
background-size: cover;
}
section#video-landing .row, section#video-landing-mobile .row {
margin: 0;
position: relative;
}
.video-caption {
position: absolute;
max-width: 550px;
top: 165px;
top: 8.5vw;
left: 0;
z-index: 99;
}
.video-caption h1, .video-caption p {
color: #000;
text-align: left;
}
.video-caption h1 {
font-size: 53px;
font-weight: 600;
}
.video-caption p.big {
margin: 0 0 30px;
max-width: 400px;
}
.video-caption p {
font-size: 17px;
}
p.big {
color: #000;
font-size: 27px !important;
font-weight: 300;
line-height: 1.5;
max-width: 850px;
margin: 0 auto;
}
video {
padding-top: 50%;
position: absolute;
top: 50%;
left: 0;
-webkit-transform: translateY(-50%);
transform: translateY(-55%);
width: 100%;
}
#video-landing, #video-landing-mobile {
width: 100%;
padding-bottom: 30%;
position: relative;
overflow: hidden;
color: white;
}
#video-landing .container, #video-landing-mobile .container {
max-width: 1140px;
}
#video-landing video, #video-landing-mobile video {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
}
I'm trying to make my footer to be always displayed on the bottom of the page when there is no enough content. I've tried several solutions but none of them worked. Also, there is a small issue with the dropdown menu - the text moves when I hover over this component. What should I change in my CSS? Thanks!
$(document).ready(function(){
$('li').hover(function(){
$(this).find('ul>li').stop().slideToggle(250);
});
});
body {
font-family: 'Roboto Condensed', sans-serif;
font-size: 18px;
color: #333;
}
p {
padding: 10px;
}
#navigation ul {
margin: 0;
padding: 0;
width: auto;
list-style-type: none;
text-align: center;
display: inline-block;
}
#navigation {
text-align: center;
}
#navigation ul li {
float: left;
font-weight: bold;
font-size: 20px;
line-height: 40px;
text-align: center;
text-shadow: 1px 1px 1px #000;
width: 140px;
}
#navigation ul li:hover {
background: #9D9FA4;
border-radius: 10px;
}
ul li a {
text-decoration: none;
color: #FFFFFF;
}
ul li li {
background: #3F61A9;
color: #fff;
display: none;
}
ul li li:hover {
background: #9D9FA4;
}
ul li li a{
text-decoration: none;
color: #fff;
}
#wrapper {
margin: 0 auto;
width: 1000px;
}
#headerwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
#header {
height: 125px;
background: #000000;
border-radius: 10px;
border: 1px solid #000000;
margin: 5px;
position: relative;
}
#navigationwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
#navigation {
height: 40px;
background: #52bf6e;
border-radius: 10px;
border: 1px solid #3ea858;
margin: 5px;
}
#contentwrap {
width: 700px;
float: left;
margin: 0 auto;
}
#content {
background: #FFFFFF;
border-radius: 10px;
margin: 5px;
}
#leftcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#leftcolumn {
border-radius: 10px;
margin: 5px;
}
#rightcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#rightcolumn {
border-radius: 10px;
margin: 5px;
}
#footerwrap {
width: 1000px;
float: left;
margin: 0 auto;
clear: both;
}
#footer {
height: 40px;
background: #9D9FA4;
border-radius: 10px;
border: 1px solid #888a91;
margin: 5px;
background-color: #9D9FA4;
text-align: center;
color: #FFFFFF;
font-weight: bold;
}
#navigationwrap_placeholder {
display:none;
height: 40px;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="wrapper">
<div id="headerwrap">
<div id="header">
</div>
</div>
<div id="navigationwrap">
<div id="navigation">
<ul>
<li>main menu</li>
<li><a>test</a>
<ul class="sub-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="navigationwrap_placeholder"></div>
<div id="leftcolumnwrap">
<div id="leftcolumn">
<p></p>
</div>
</div>
<div id="contentwrap">
<div id="content">
<br><br>
<p>Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices. Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. </p>
<br><br>
</div>
</div>
<div id="rightcolumnwrap">
<div id="rightcolumn">
<p></p>
</div>
</div>
<div id="footerwrap">
<div id="footer">
</div>
</div>
</div>
</body>
</html>
You need to use position:fixed to put the footer at the bottom of the page.
#footerwrap {
width: 1000px;
margin: 0 auto;
position: fixed;
bottom:0;
}
As for the text shifting slideToggle seems to be shifting the padding of the test list item. By setting the padding in the style itself it fixes the problem.
<li ><a style="padding:0 38%">test</a>
Here is a working snippet that solves your navigation issue. I added comments in the CSS so you can better understand what changes I made. I used some flex-box to fix the issue. Super simple. As for the footer, there are lots of ways you can achieve this so I will post a link to an article that shows you 5 different ways to do it and you can pick whichever one works best for your use case. Hope this helps :)
P.S. As a side note, I noticed in your markup that you had a class called sub-menu which is not being used in your CSS. Not a big deal just thought I'd point it out. You probably have plans for it later on.
Here are some footer options
$(document).ready(function() {
$('li').hover(function() {
$(this).find('ul>li').stop().slideToggle(250);
});
});
body {
font-family: 'Roboto Condensed', sans-serif;
font-size: 18px;
color: #333;
}
p {
padding: 10px;
}
/* removed display property as it was not needed
display inline-block was causing the nav item to shift over*/
#navigation ul {
margin: 0;
padding: 0;
width: auto;
list-style-type: none;
}
#navigation {
text-align: center;
}
#navigation ul li {
float: left;
font-weight: bold;
font-size: 20px;
line-height: 40px;
text-align: center;
text-shadow: 1px 1px 1px #000;
width: 140px;
}
#navigation ul li:hover {
background: #9D9FA4;
border-radius: 10px;
}
ul li a {
text-decoration: none;
color: #FFFFFF;
}
ul li li {
background: #3F61A9;
color: #fff;
display: none;
}
ul li li:hover {
background: #9D9FA4;
}
ul li li a {
text-decoration: none;
color: #fff;
}
#wrapper {
margin: 0 auto;
width: 1000px;
}
#headerwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
#header {
height: 125px;
background: #000000;
border-radius: 10px;
border: 1px solid #000000;
margin: 5px;
position: relative;
}
#navigationwrap {
width: 1000px;
float: left;
margin: 0 auto;
position: relative;
}
/* Added display flex to container with
justify-content center to keep nav items aligned*/
#navigation {
height: 40px;
background: #52bf6e;
border-radius: 10px;
border: 1px solid #3ea858;
margin: 5px;
display: flex;
justify-content: center
}
#contentwrap {
width: 700px;
float: left;
margin: 0 auto;
}
#content {
background: #FFFFFF;
border-radius: 10px;
margin: 5px;
}
#leftcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#leftcolumn {
border-radius: 10px;
margin: 5px;
}
#rightcolumnwrap {
width: 150px;
float: left;
margin: 0 auto;
}
#rightcolumn {
border-radius: 10px;
margin: 5px;
}
#footerwrap {
width: 1000px;
float: left;
margin: 0 auto;
clear: both;
}
#footer {
height: 40px;
background: #9D9FA4;
border-radius: 10px;
border: 1px solid #888a91;
margin: 5px;
background-color: #9D9FA4;
text-align: center;
color: #FFFFFF;
font-weight: bold;
}
#navigationwrap_placeholder {
display: none;
height: 40px;
}
<html>
<head>
<meta charset="utf-8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="wrapper">
<div id="headerwrap">
<div id="header">
</div>
</div>
<div id="navigationwrap">
<div id="navigation">
<ul>
<li>main menu</li>
<li><a>test</a>
<ul class="sub-menu">
<li>test1</li>
<li>test2</li>
<li>test3</li>
<li>test4</li>
</ul>
</li>
</ul>
</div>
</div>
<div id="navigationwrap_placeholder"></div>
<div id="leftcolumnwrap">
<div id="leftcolumn">
<p></p>
</div>
</div>
<div id="contentwrap">
<div id="content">
<br>
<br>
<p>Sed lacinia, urna non tincidunt mattis, tortor neque adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti. Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices.
Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna. Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue eget diam. Vestibulum ante ipsum primis in faucibus orci
luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. Praesent blandit dolor. </p>
<br>
<br>
</div>
</div>
<div id="rightcolumnwrap">
<div id="rightcolumn">
<p></p>
</div>
</div>
<div id="footerwrap">
<div id="footer">
</div>
</div>
</div>
</body>
</html>
I'm having issues forcing a link to take full height of its parent container.
Here is a Fiddle of my code: http://jsfiddle.net/z2ua5g4j/
a > span.button-single {
font-size: 30px;
color: #fff;
display: block;
margin-bottom: 8px;
margin-left: 0px;
}
.box {
background-color: #f5f5f5;
border: 1px solid #dcdcdc;
height: 100%;
}
.box h1 {
color: #667477;
font-size: 24px;
margin-left: 20px;
}
.box p {
color: #b1b1b1;
font-size: 13px;
margin-left: 20px;
margin-bottom: 20px;
}
.box a.button {
width: 95px;
background-color: #b4b4b4;
margin-right:-1px;
color: #fff;
padding-top: 13px;
padding-bottom: 13px;
font-size: 15px;
line-height: 16px;
text-align: center;
float: right;
height: 100%;
display: block;
}
.box a.button:hover {
text-decoration: none;
background-color: #a7a7a7;
}
Basically, I want to make the gray button (on the right) take full height of the box container. As of writing, I've tried setting the link to display block and set its height to 100%, but with no avail.
Any ideas?
I changed box to 100px, and setup parent elements of the button to have 100% height
However, you still may want to take a look at http://webdesign.about.com/od/csstutorials/f/set-css-height-100-percent.htm to understand how height:100%; is different from width:100%;. I'm guessing you believe they work the same.
#import url("http://getbootstrap.com/dist/css/bootstrap.min.css");
a > span.button-single {
font-size: 30px;
color: #fff;
display: block;
margin-bottom: 8px;
margin-left: 0px;
}
.box {
background-color: #f5f5f5;
border: 1px solid #dcdcdc;
height: 100px;
}
.box h1 {
color: #667477;
font-size: 24px;
margin-left: 20px;
}
.box p {
color: #b1b1b1;
font-size: 13px;
margin-left: 20px;
margin-bottom: 20px;
}
.box a.button {
width: 95px;
background-color: #b4b4b4;
margin-right:-1px;
color: #fff;
padding-top: 13px;
padding-bottom: 13px;
font-size: 15px;
line-height: 16px;
text-align: center;
float: right;
height: 100%;
display: block;
}
.box a.button:hover {
text-decoration: none;
background-color: #a7a7a7;
}
.row{
height: 100%;
}
<div class="box">
<div class="row">
<div class="col-sm-10">
<h1>Title</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla bibendum purus ut pretium ultricies. Cras pulvinar tincidunt lorem, ut posuere risus mollis in. Fusce pharetra urna nec sagittis suscipit.</p>
</div>
<div class="col-sm-2" style="height:100%;">
<span class="button-single glyphicon glyphicon-plus-sign"></span> More<br/>Details
</div>
</div>
</div>
Just use the btn-block class instead of messing around with div heights, like this:
<div class="col-md-3"><button class="btn btn-block" >Show Details</button></div>
Another vertical alignment question...
Given the following,
HTML:
<div class="thing">
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et tempus mauris. Vivamus imperdiet congue iaculis.</h2>
</div>
<div class="thing">
<h2>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec et tempus mauris.</h2>
</div>
CSS:
.thing{
background: #eee;
margin: 0 auto 10px;
width: 625px
}
h2{
display: inline-block;
font-size: 15px;
line-height: 20px;
margin: 0 0 0 40px;
vertical-align: middle;
}
.thing:before{
background: red;
content: '';
display: inline-block;
height: 40px;
position: absolute;
vertical-align: middle;
width: 40px;
}
What do I need to do in order to have the text and the red box vertically centered? This should work for headings of any height.
Fiddle
You just need to remove the position:Absolute that breaks the inline-block behavior. Instead use some trick to fight the space between inline-block elements and be sure the two elements can be aside on the containers width. Try this:
.thing{
font-size:0; /*ADD*/
}
h2{
/*margin: 0 0 0 40px; REMOVE*/
width:585px; /*ADD*/
}
.thing:before{
/*position: absolute; REMOVE*/
}
Check this Demo Fiddle
I guess your question has two answers.
Here's solution one: (Make the red box equal the height of the .thing content.
.thing{
background: #eee;
margin: 0 auto 10px;
position: relative; // Make .thing:before relate it's position to this
width: 625px
}
h2{
font-size: 15px;
line-height: 20px;
margin: 0 0 0 40px;
}
.thing:before{
background: red;
content: '';
height: 100%; // Height will equal .thing height
position: absolute;
width: 40px;
}
Demo 1
Second solution: (Make text center vertically)
.thing{
background: #eee;
margin: 0 auto 10px;
min-height: 40px;
position: relative;
width: 625px
}
h2{
font-size: 15px;
line-height: 20px;
margin: 0 0 0 40px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
.thing:before{
background: red;
content: '';
height: 40px;
left: 0;
position: absolute;
top: 0;
width: 40px;
}
Demo 2