I have following structure: JSFiddle Demo
HTML & CSS Code is as following:
HTML:
<ul>
<li class="test"> Hello </li>
<li class="test"> Welcome </li>
<li class="test"> Test Process </li>
<li class="test"> Text Message </li>
</ul>
CSS
ul{
width: 100%;
}
.test{
height:20px;
width:20%;
border: 1px solid black;
border-radius: 3px;
display: inline-block;
float: left;
margin-left: 5px;
text-align: center;
}
When I resize the browser the <li> tag widget structure is working fine (Not breaking) but the text inside the widget are breaking like:
My question is How can I make the text inside the widget adjustable so that It will not break.
Is there any way to fix this using only CSS ?
Provide
min-width:20%;
instead of
width:20%;
It should work..
Fiddle: http://jsfiddle.net/ZZa8j/2/
If you want it to expand accordingly, you can simply remove the explicit height and set a min-height like this.
If you want to clip the text and indicate the user that text is clipped, you can use the text-oveflow property like this.
.test{
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
/*other styles*/
}
If you actually want the content to expand as much as possible and scoll if not, you could use Paulie_D's table-cell approach like he mentioned in comments.
Your images are blocked by my proxy so I'm not sure if it's the answer that you need, but you can avoid break between 2 words with the css property white-space.
white-space:nowrap;
see fiddle : http://jsfiddle.net/ZZa8j/4/
add min-width:450px; to the <ul>.
check my Fiddle Demo
CSS
ul{
min-width:450px;
width: 100%;
}
.test{
height:20px;
width:20%;
border: 1px solid black;
border-radius: 3px;
display: inline-block;
float: left;
margin-left: 5px;
text-align: center;
}
HTML
<ul>
<li class="test"> Hello </li>
<li class="test"> Welcome </li>
<li class="test"> Test Process </li>
<li class="test"> Text Message </li>
</ul>
Result
Code Demo
Try :
overflow: hidden;
min-width:100px;
Related
I have a div with this style:
#menudiv{
width:20%;
padding:3px;
float:left;
height:100%;
font-family:ubuntu;
font-size:25px;
color:#404040;
}
The problem is that although the div is placed correctly and has the right visual attributes, the content in this div is disabled. As in, the data cannot be selected with click-moving the mouse and the links in this place are unclickable :S
What am I doing wrong here?
P.s. there are two other divs in this section of the page which these styles:
#content{
position:relative;
}
div.sidebar{
float:right;
margin-right:25px;
margin-left:5px;
padding:5px;
font-family:verdana;
font-size:10pt;
width:300px;
border:solid 2px #a0b0c0;
display:flex;
text-align:justify;
}
The content in these divs is normal and can be interacted with.
The content in the div is this:
<div id="menudiv">
<img class="titleico" src="images/home.png" /> HOME<br />
<ul id="menulist">
<li>Menu item 1</li>
<li>Menu item 2</li>
</ul>
</div>
UPDATE 2
You can check the whole thing # http://daera.net/daera
The leftmost div (the one with HOME text and 2 list items) has the problem.
If your HTML/CSS/Javascript/JQuery code contains the following, please remove them...
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select:none;
user-select:none;
-o-user-select:none;
unselectable="on"
onselectstart="return false;"
onmousedown="return false;"
Option 1
remove this block from the code
#contentdiv {
position: relative;
}
Option 2
#contentdiv {
position: relative;
float: left;
width: 200px; // give what ever required
}
issue will be resolved
Well, I coded this page, but I got stuck at why does the third column is pushing down my text (or other elements). It uses the same style from the first box, but while the first box is ok, the third one is pushing the elements down by some pixels.
Like this:
HTML
<div id="contentWrapper">
<div id="sideBar">
<div class="sidebarBox"></div>
<div class="sidebarContent">
<h4>
Índice
</h4>
<ul class="tree">
<li>
Sinopse
</li>
<li>
Tropas
</li>
<li>
Geladeira
<ul>
<li>
Lógica
</li>
<li>
Gênio
</li>
<li class="last">
Horror
</li>
</ul>
</li>
<li>
Notas
</li>
<li>
Mídia
</li>
<li class="last">
Referências
</li>
</ul>
</div>
</div>
<div id="mainBody"></div>
<div id="infoBar">
<div class="sidebarBox"></div>3º Column
</div>
</div>
CSS
* {
margin:0;
padding:0;
font:normal normal 14px/20px Helvetica,Arial,sans-serif
}
h4 {
font-size:14px;
font-weight:700;
text-transform:uppercase;
padding-top:10px;
border-bottom:2px solid #2a558c;
margin-bottom:10px
}
#contentWrapper {
display:table;
border-spacing:0;
width:100%;
height:500px
}
#contentWrapper > div {
display:table-cell
}
#sideBar {
background-color:#E4E5DD;
width:200px
}
#mainBody {
background-color:#EEEEE6
}
#infoBar {
background-color:#e4e5dd;
width:200px
}
#footer {
background-color:#323540;
height:50px
}
.sidebarBox {
background-color:#323540;
height:30px;
width:100%
}
.sidebarContent {
padding:15px
}
I messed a lot with the Firebug and even tried to open it in IE and Chrome, with same results. Both columns use the same CSS, and this difference is freaking me out. I thought about "fixing" it with some negative margins, but I want to understand the problem first, insted of "workahacking" away.
Thanks a lot in advance!
Add vertical-align: top to #contentWrapper > div. Currently it is baseline.
Have a fiddle!
CSS
#contentWrapper > div {
display: table-cell;
vertical-align: top;
}
Without vertical-align: top, the div is basing its vertical alignment on .sidebarContent which has 15px of padding. This is resulting in the 15px gap.
Change the following and it should fix your problem. I've found that when using display:table-cell it always mis-aligns the last cell unless I specifically give it a vertical alignment
#contentWrapper > div {
display: table-cell;
vertical-align:top;
}
Example
Add display:inline-block to this class:
.sidebarBox {
background-color: #323540;
height: 30px;
width: 100%;
display: inline-block;/*Add this*/
}
fiddle
.sidebarBox {
float:right;
}
will work.
I am new to HTML, I have created circle using border-radius and i have put some text in it. the Text is displaying on the lower part of the Box and its also appearing after the circle. I want to put the Text in the circle.
Kindly check this and guide me.
<ul>
<li>HOME</li>
<li id="skills" class="navText" >Work - Work Experience</li>
<li id="web" class="navText">Skills </li>
<li id="video1" class="navText">Web - Web Projects </li>
<li id="video2" class="navText">Video - Video Projects </li>
</ul>
Style
#navText
{
position:absolute;
top:-90px;
}
nav ul
{
list-style-type:none;
padding:0;
margin:20px 0px 0px 130px;
}
nav ul #skills
{
position:absolute;
line-height:-200px;
background-color:#EA7079;
display: inline-block;
border:6px solid;
border-color:white;
border-radius:110px;
padding: 91px 31px 31px ;
width:80;
height:25;
text-align:center;
#margin-left:35px;
}
Line-height equal to height of the div/li also works - FIDDLE
This works fine for short lines, for long lines, you'll have to use another technique as mentioned.
The top circle in the fiddle is a div in a div changed to inline-block
CSS
.centerofcircle1 {
width: 100px;
height: 100px;
border-radius: 50%;
line-height: 100px;
font-size: 15px;
background-color: red;
color: white;
text-align: center;
}
This is one of the thing that css dosen't do very well. However there is a solution, here is a great article by Chris Coyier that helped me with this problem.
You could add the vertical-align property to your text class.
vertical-align: middle;
Also, if that doesn't work, try to manually place in the middle with margin-bottom or/and margin-top.
margin-bottom: 10px;
And your #navText is an id. Use div id="navText" instead of class="navText"
I'm displaying a set of thumbnail images with links on a webpage like this
Here's the HTML
<div id="newsletters-and-journals">
<p id="pubs-caption">Publications</p>
<ul>
<li class="pubs">
<img class="pub-cover" src="images/CXuyv.png" />
<span>Journal - January 2012</span>
</li>
<li class="pubs">
<img class="pub-cover" src="images/vER9H.png" />
<span>Newsletter - May 2012</span>
</li>
</ul>
</div>
and the CSS
#newsletters-and-journals ul { position:relative; top:12px; left:30px; }
.pubs { display:inline; margin-right:60px; }
.pub-cover { width:120px; height:140px; }
also a fiddle http://jsfiddle.net/nK0de/3jeVF/2/
How can I display the links under each corresponding image?
Thank you
It is also works:
.pubs {
display: inline-block;
margin-right: 60px;
width: 120px;
}
width is your image's width.
You can make either <img> or <span> to display:block
http://jsfiddle.net/3jeVF/6/
to solve your problem just add a
br
tag in between
img and span tag.
I need to change something without touching HTML codes.
So I have this code in my HTML
<span class="share">
<ul>
<li>Share </li>
<li class="twitter">twitter</li>
<li class="facebook">facebook</li>
<li class="delicious">delicious</li>
<li class="friendfeed">friendfeed</li>
<li class="addthis">share</li>
<div class="clear"></div>
</ul>
</span>
and this in CSS
.twitter {
background: url('../images/tt.png') no-repeat;
width: 10px;
height: 14px;
}
This works fine, but twitter text is visible under the twitter logo, I don't want those texts to appear in my list, I want to replace them with images in CSS.
Is it possible to do without touching HTML Codes?
Make the text transparent. Since it's a link, you'll want to use a few selectors to make sure all cases are addressed:
.twitter a, .twitter a:link, .twitter a:visited
{
color: transparent;
}
Edit: This other option, while more verbose, has the benefit of keeping the focus border (the little dots that appear when a link is selected) to the size and shape of the twitter icon. Also, the text will not be revealed if selected and copied and pasted. It becomes invisible and unselectable. Here is the technique:
.twitter a {
display: inline-block;
overflow: hidden;
width: 0;
height: 14px;
padding-left: 10px;
}
You could use text-indent:
text-indent: -9999px; /* get rid of any text */
Try making your font-size : 0px; in your css.
use text-indent with a little magic in it :)
HTML:
<span class="share">
<ul>
<li>Share </li>
<li class="twitter">twitter</li>
<li class="facebook">facebook</li>
<li class="delicious">delicious</li>
<li class="friendfeed">friendfeed</li>
<li class="addthis">share</li>
<div class="clear"></div>
</ul>
</span>
CSS:
a.twitter {
background-image:url('../images/tt.png');
display:block;
height:58px;
text-indent:-9999px;
width:200px;
}
So you see the text is indented but still the image is still clickable because i've put a class in the twitter link ;)