I need to create a filmstrip kind of div which contains images in a single line without wrapping over. As a trial I am trying to create a div in which I can have text which does not wrap over. Sadly I am unable to figure out how to do it, I am not very good with CSS... Can anyone help?
So far I have done:
<style>
.filmstrip
{
background-color:silver;
padding:20px;
overflow-x:scroll;
display: inline-block;
}
</style>
<div class='filmstrip'>
This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test
</div>
I want "This is a test" to come in a single line. (Like how it is in SO). However in my page, it wraps around...
I am now able to show text without scroll from help in comments section...Im adding original problem statement here about showing images without wrap
I have an array of images inside $images. I want to show these images in single line inside div. I tried following based on comments here:
<style>
.filmstrip
{
background-color:silver;
padding:20px;
overflow:scroll;
white-space: nowrap;
}
</style>
<div class='filmstrip'>
<?php
foreach($images as $image)
{
echo "<div><img src='".$image->thumbnail."'></div>";
}
?>
</div>
But this is still coming as separate lines...
Try like this: Demo
.filmstrip {
width:80%;
border:2px solid #000;
overflow:auto;
white-space:nowrap;
}
.filmstrip img {
margin:20px 10px 0 10px;
width:140px;
height:140px;
}
Updated demo without margin:
.filmstrip {
width:80%;
background-color:silver;
overflow:auto;
white-space:nowrap;
padding:20px;
}
.filmstrip img {
width:140px;
height:140px;
border:1px solid #000;
}
If you want all the text to come in a single line, then you have to add
white-space:nowrap;
To see all the text in a single line you have to add overflow: scroll
According to my knowledge this fiddle will help you.
Code
.filmstrip
{
background-color:silver;
padding:20px;
overflow-x:scroll;
display: inline-block;
width: 600px;
overflow: scroll;
white-space:nowrap;
}
<div class='filmstrip'>
This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test This is a test
</div>
If you want the images to come in a single line, simply you have to add all the img tags inside the div.
By default is a inline element, so it will align in a same line, adding white-space:no-wrap, you will get all images in a same line without break.
Fiddle for image in single line.
Check this out:
https://jsfiddle.net/0cddc72t/5/
CSS
.filmstrip
{
background-color:silver;
padding:20px;
overflow-x:scroll;
display: inline-block;
width: 600px;
overflow: scroll;
white-space:nowrap;
}
.filmstrip > div {
display: inline-block;
background-color: #333;
}
Is this what you want?
Related
I have the following RSS feed:
https://jsfiddle.net/yhtf36a1/
Right now, it gets displayed one below the other.
How do I use CSS to make it display two items per row, so that it looks like the following?
I tried using display:inline-block but that didn't work.
Use the following CSS:
.entry-wrapper {
float:left;
width: 48%;
background: lightblue;
margin: 1%
}
See the example here: jsfiddle.net/GillesCoeman/5e8z00z1
Hope this helps
*{font-family:arial}
.rssRow{display:flex}
.entry-wrapper{display:inline-block; margin:.25em;background:#f3f3f3; border:3px solid #f1f1f1; background:#FFF;padding:10px;border-radius:5px;}
.entry-wrapper:hover{background:#edfdff;border:3px solid #f4f4f4}
.entry-image{float:left;}
.entry-text{float:left;}
.entry-title h4{margin:0; font-size:1.5em;font-weight:bold;}
.entry-title h4 a {color:#333; text-decoration:none;}
.entry-title h4 a:hover{text-decoration:underline;}
.entry-date{color:#999; padding-bottom:.75em;font-size:.75em}
Preview at https://jsfiddle.net/itsselvam/yhtf36a1/3/
Let me know for any query on this
hi im pretty new to doing front-end stuff i have this div that contains this mini divs inside it when it only have a p tag input here is how it looks like
but when i added my code for its contents, the div misaligned
and now it looks like this
so fare here is the codes im working with
<div id="tabular" style="display:none">
#foreach($NSAdata as $list)
<div class="divcont">
<p>Filename :</p>{{$list->filename}}
</div>
#endforeach
</div>
.divcont
{
background-color: pink;
display: inline-block;
width: 300px;
height: 150px;
margin-bottom: 1%;
margin-right: 1%;
}
#tabular
{
height: 28.125em !important;
overflow-y: auto;
}
any idea what im doing wrong? or to improve my code?
Adding vertical-align: top; to your inline blocks should fix it.
.divcont {
...
display: inline-block;
vertical-align: top;
}
The reason is the default value of vertical-align is baseline, when your content inside the inline blocks has different length/height, that causes the mis-alignment.
Inline-block elements are whitespace dependent, which means spaces in your HTML are spaces on screen.
Try and remove the extra blank line at the start of your #foreach loop.
Also add white-space: nowrap; to the #tabular parent div
First question, so be forgiving if you can:
Using PHP I've created a site where users enter info and it is saved to database. Users then style each entry (font, size, color, and location). A string is saved into the database for each parameter, and then I use PHP to echo out a DIV with the custom styling:
echo "<div id=\"customized\"";
if(isset($backtype)){if($backtype == "image") {echo "style=\"background-image:url('".$backurl."');
background-repeat: no-repeat; background-size: 400px 200px\"";}}
if(isset($backtype)){if($backtype == "color"){echo "style=\"background-color:".$backcolor."\"";}}echo ">";
if($namepos !== ""){echo "<div id=\"".$namepos."\" style=\"font-family:".$namefont."; font-size:".$namesize."; color:".$namecolor.";\">".$name."</div>";}
After getting strings from database this becomes:
<div id="customized" style="background-image:url('raptor.gif'); background-repeat: no-repeat; background-size: 400px 200px ">
<div id="3_1" style="font-family:Courier New; font-size:20pt; color:#f80a8c;">Text here</div></div>
When this DIV is created all the inline styling works, but the location it display is supposed to be dictated by the $namepos, which echoes out "3_1".
I have an external CSS as follows
#customized {
border: 1px solid grey;
margin: 3px;
position: absolute;
top: 7%;
left: 1%;
width: 400px;
height: 200px;
}
#3_1{
position: absolute;
white-space: nowrap;
top:10%;
left:5%;
}
The final output completely ignores this CSS for the div that is produced by doing echo $namepos, but works perfectly fine for the containing div id=" customized".
I fear that I already know the answer and that it just doesn't work for the dynamically named DIV, but I'm an amateur and if this is true then it's a serious setback, so I come here hoping for a savior.
Any help would be greatly appreciated.
It was the DIV starting with a number, wouldve never figured that out. much thanks for speedy reply. will now sleep without debugging nightmares.
Well, I have sidebar but text(in my case tables) inside sidebar are not aligned like I want.
From one .php I call another inside sidebar, like this:
<div id="sidebar2"> <?php include("tiket.php");?></div>
Here is it CSS of sidebar:
#sidebar2 {
width: 240px;
float: right;
padding: 40px;
background: #264988;
color: #e1d2c7;
margin: 5px;
text-align:justify;
}
An this is how it looks:
How to put text on the left of the sidebar?
It would help a lot if you gave us the complete source code of the sidebar, or told us where it was located.
I think that the reason why the text is not aligned to the left is because you put in text-align:justify;. Remove that line.
#sidebar2 {
width: 240px;
float: right;
padding: 40px;
background: #264988;
color: #e1d2c7;
margin: 5px;
}
What justify does is spread the text out evenly, which can be unhelpful if you don't have much text.
You can nest with CSS3
#sidebar2 table {
text-align: left;
}
you can read more about it over here
https://www.w3schools.com/css/css_combinators.asp
This is the code for my next/prev navigation found at http://ilikeyou.tk/763/ :
<div class="navigation">
<? if($nexts['id'] == ''){ ?>
<? }else{ ?>
<? } ?>
</div>
I would like to vertically center the buttons. I tried using vertical-align:middle; which didn't work. I also tried top:50%; but that didn't do the job either.
Here is my css:
.navigation {
position: relative;
float: left;
vertical-align : middle;
height: auto;
padding: 0;
margin: 0 -20px 0 -22px;
width: 636px;
z-index:1;
}
.navigation a.prev{
background: url('images/nav_left.png');
float: left;
width: 50px;
height: 50px;
margin-left:10px;
}
.navigation a.next {
background: url('images/nav_right.png');
float: right;
width: 50px;
height: 50px;
margin-right:10px;
}
Thanks!
So, I'm guessing that the content area height is not very static.
http://jsfiddle.net/aBzhu/
Trick is to have the outer element set to position: relative; float: left; and then the element you want to center as position: absolute; top: 50%; margin-top: -Half_the_height_of_this_element;
Note that this only works when the element that you want to center vertically IS static height. Should fit your usage I think.
Edit: Oh.. and I dont think this necessarily works in ie6. But does work ie7+
Edit2: Also if youre not interested in such a puny methods you should check this out Using jQuery to center a DIV on the screen
vertical-align is intended for table cell rendering, and even this is quite problematic. Why not just add a few pixels of top padding to your navigation ul? It's not real centering, but you're obviously not worried about dunamic scaling when you're using a fixed height graphic for the navigation background.
This Solution Matched me perfectly for small texts. Even if it is a link or just a text inside the div, this CSS Class could vertically align the content inside the DIV. Works for IE as well..
.verticalCenterDivText{
height: 29px;
line-height: 29px;
}
Hope this helps....
Regards, ADynaMic