MKGamer100 Posted April 16, 2015 Share Posted April 16, 2015 Hello everyone, this is my first post here and i need some help. I am making a website about tanks. I am building her via PHP, CSS and HTML. Now i made a div called lastnewstanks and css for that div is: #lastnewstanks { margin-left:8.5px; margin-top:10px; width:31.5%; display:inline-block; background-color:#222222; height:300px; color: #33CC33;} My page displays 3 divs because i did this code: $result = mysql_query("SELECT * FROM tanks ORDER BY ID DESC LIMIT 3");while($row = mysql_fetch_array($result)) { $id = $row['id']; $textforfun = $row['text']; $image = $row['image']; $title = $row['title'];echo "<div id='lastnewstanks'>";echo "<img src='$image' alt='' style='width:100%;height:45%'>";echo "<h4>$textforfun</h4>";echo "</div>"; } But when i have different number of characters in that divs that div which have less number of characters go down.Sorry for my English but i'll put some images....2 images: One picture is with different number of characters, and other one is with same number... Link to comment Share on other sites More sharing options...
mannemvamsi Posted April 16, 2015 Share Posted April 16, 2015 For repeating divs it is best to use "class" instead of "Id" see here http://jsfiddle.net/mannemvamsi/w27hcLx0/ Link to comment Share on other sites More sharing options...
dsonesuk Posted April 16, 2015 Share Posted April 16, 2015 id singular to a page, class can be used multiple times within a page, using display: inline-block; makes these elements act like text, the default vertical alignment for text is baseline, and that is the rule it is following. To align at top use vertical-align: top; 1 Link to comment Share on other sites More sharing options...
MKGamer100 Posted April 16, 2015 Author Share Posted April 16, 2015 Works great Mr. Dsonesuk. Thank You Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now