I'm trying to customise my blog on Tumblr, but I'm having some trouble. What I want is a picture centered horizontally in my blog, with a next and previous button around it. It should look like
O [__] O
where the O's are my buttons and the [_] represents my picture.
How do I get the three elements together to be centered on my page and the buttons a certain amount of pixels away from the picture? Both buttons each have their own DIV, the photo has a class and there is one DIV enclosing the three of them.
My HTML is like this:
<div class="photo-wrap">
<div id="previous">
<img src="http://static.tumblr.com/gptupvc/hUhlxhrgd/next.png"></img>
</div>
{block:Posts}
{block:Photo}
<center>
<img class="photo" src="{PhotoURL-HighRes}"></img></center>
{/block:Photo}
{/block:Posts}
</div>
<div id="next">
<img src="http://static.tumblr.com/gptupvc/hUhlxhrgd/next.png"></img>
</div>
with the following CSS
.photo-wrap {
position:relative;
margin-top:50px;
width:1200px;
margin-left:auto;
margin-right:auto;
background-color:red;
}
.photo {
float:left;
height:600px;
border-radius:10px;
}
#next {
float:right;
margin-top:-350px;
background-color:green;
}
#next img {
width:100px;
height:100px;
}
#previous {
float:left;
margin-top:250px;
background-color:red;
}
#previous img {
width:100px;
height:100px;
}
Use a table! Ha! I know. We aren't "allowed". I don't have tumblr. But I can answer this generally for any HTML.
Put your three widgets into a div and style it with style="text-align:center". Now, anything you put inside of that div will be centered.
<div style="text-align:center">Stuff</div>
Next, put each of the widgets into their own divs and style them so that they appear "inline"
<div style="text-align:center">
<div style="display:inline">Previous</div>
<div style="display:inline">Button</div>
<div style="display:inline">Next</div>
</div>
Last, you want spacing -- so fiddle with margin and padding until you get what you want. For instance, try this:
<div style="text-align:center">
<div style="display:inline">Previous</div>
<div style="display:inline;margin-left:25px;">Button</div>
<div style="display:inline;margin-left:25px;">Next</div>
</div>
And you'll probably want to put all that styling in CSS ultimately. But do that last.
By the way, another way to achieve horizontal spacing is to use "margin:0 auto" on the containing div.
Vertical centering is something all together different, but you didn't ask about that.
Good luck!
I would suggest you to try this code
<style type="text/css">
#image{float:left;}/*this is the important part to set float*/
#male{float:left;}
</style>
<form>
<input id="male" type="radio" name="sex" value="male" > Male
<div id ="image"><img border="0" src="/images/pulpit.jpg" alt="Pulpit rock" width="304" height="228" /></div>
<input type="radio" name="sex" value="female" /> Female
</form
Related
In the codes below, I have two <div> tags. I want to align one <div> to the left and the other to the right, with the same height and width. Please help me to do this.
<div id="imgShow">
<panel>
<img class = "hidden" id="orginal" alt = "Goofy pic of me" runat="server" />
<div id="ScrollImg" style="position:relative;width:900px; height:330px;overflow: scroll; top: 3px; left: -1px;left:auto">
<canvas id = "drawing" height="1500" width="1200" >
<p>Canvas not supported</p>
</canvas>
</div>
</panel>
</div>
<div id="divComplete" style="position:relative;width:100px; height:330px;overflow: scroll; top: 3px; right: -1px;right:auto"></div>
Set the floats for each div with CSS: example
.left { width:50%; float:left; height:200px; background:red;}
.right { width:50%; float: right; height:200px; background: blue;}
Try below code:
Demo
<div id="imgShow" style="width:50%; height:330px;overflow: scroll;float:left;">
<panel>
<img class = "hidden" id="orginal" alt = "Goofy pic of me" runat="server" />
<div id="ScrollImg">
<canvas id = "drawing" height="1500" width="1200" >
<p>Canvas not supported</p>
</canvas>
</div>
</panel>
</div>
<div id="divComplete" style="width:50%; height:330px;overflow: scroll;">Canvas not supported</div>
You should use floats:
<style>
#imgShow, #divComplete{
float:left;
width:50%;
}
</style>
If you want both at different widths, simply separate the css selectors and add the desired width.
PS: Avoid using inline CSS unless you need to, transfer these to a separate CSS file and include it in the head section
You can use twitter bootstrap css for styling your divs. Simply addclass="col-xs-6" to each div. Remember class="col-xs-12" is the full width that the div can take based on the width of the parent container. Using -xs- instead of -md- shrinks the div upon resize instead of knocking them down. If you want margins simply add change them to col-xs-5s then add a col-xs-2 div in between. It's also good practice to use parent divs with container-fluid and row classes
So, I did a search and it seems that every single person who's asked this exact same question has actually had success with an answer given by someone - I tried multiple different methods and honestly, I'm about to have a meltdown.
I've tried floating left, floating right, inline-block, etc, and none of it has seemed to work. I am at a loss as to what I'm doing wrong, but it's driving me nuts.
Here's the HTML I'm trying to get on the same line:
<div class="search-and-staff-app-button">
<div class="search-position">
<form method="get" id="sb_searchform" action="<?php bloginfo('home'); ?>/">
<div class='search-box'>
<input name="s" id="s" class='search-input' placeholder='Search' type='text' />
<img onclick="document.getElementById('sb_searchform').submit();" class='search-img' src='<?php bloginfo('template_url'); ?>/img/search.png'>
</div>
</form>
</div>
<div id="staffAppButtonPlaceholder" class="staff-app-position"></div>
</div>
and the CSS:
.search-and-staff-app-button {
width:360px;
margin:0px;
float:right;
display: inline-block;
}
.search-position {
float:left;
}
.staff-app-position {
float:left;
}
What am I doing wrong? I've tried Getting 2 divs on the same line and this doesn't work either.
Any help would be super appreciated!
-Stu
To place the search-position and staffAppButtonPlaceholder divs on the same line, first float the search-position div:
.search-position {
float: left;
}
Then add some content to the placeholder:
<div id="staffAppButtonPlaceholder" class="staff-app-position">Content</div>
Finally, increase the width of the containing div to allow the elements to fit side-by-side:
.search-and-staff-app-button {
width:760px;
Both divs will now be aligned horizontally.
http://jsfiddle.net/jzefu2j9/1/
Here is a little example, maybe it will help you. I used flexbox, which in my opinion is a great solution for aligning.
.search-and-staff-app-button{
display: flex;
background:red;
align-items:center;
}
.search-and-staff-app-button > div{
box-sizing:border-box;
display:block;
flex:1 50%;
align-self:center;
padding:1em;
}
http://jsfiddle.net/pulamc/u9nLwacs/
add style="position:relative" to your outer div. Then make the inner div's style="position:absolute;left:0". You will have to manually set the left value for each of the divs. The downside is that you will have to know the width of the other divs on the same line.
I have an image in my HTML code:
<img src="main.jpg" />
I want to show a smaller linkable image over main.jpg when I hold mouse over main.jpg.
(This image is link)
I prefer to use smaller image by CSS.
I tried this:
<div class="img"><img src="main.jpg" /></div>
<div class="resize">resize imgae</div>
.resize{
background:url(resize.jpg) left top no-repeat;
position:absolute;
top:0;
left:0;
desiplay:none;
text-indent: -9999px;
}
I want do this just with pure CSS (no JS)...Do you know a trick or an alternative way to do it?
this will solve your problem
<div class="img">
<img src="main.jpg" />
<div class="resize">resize imgae</div>
</div>
Also correct your css class
change desiplay:none; to display:none;
Hello I have created two divs, one is floated to the left (button), and has 120px width, and another one is for textarea, textarea should be margin-left: 20px and take rest of the width. How much ever I try, I am not able to achieve this. Guys, do you know the solution?
<div id="button" style="float: left; width: 120px; height: 80px;">
<input type="button" id="button" value="something" />
</div>
<div id="textarea" style="margin-left: 20px;">
<textarea id="message"></textarea>
</div>
(For IE8 use #ID named DIVs instead of nth-child)
DEMO
|-------- 120 --------| 20 |------ available space ----------------------------------------------------------->
<div id="formArea">
<div>
<input type="button" value="something" />
</div>
<div>
<textarea></textarea>
</div>
</div>
#formArea{
display:table;
width:100%;
}
#formArea>div{
display:table-cell;
vertical-align: top;
}
#formArea>div:nth-child(1){
width:120px;
}
#formArea>div:nth-child(2){
padding-left:20px; /* instead of margin */
}
#formArea textarea{
border:0;
width:100%;
}
And remember, ID must be unique-per-page.
Try this:
CSS
.left{
float:left;
width:120px;
}
.right{
overflow:hidden;
margin-left:20px;
}
#message{
width:100%;
}
HTML
<div class="left">
<input type="button" id="button" value="something" />
</div>
<div class="right">
<textarea id="message"></textarea>
</div>
fiddle
Let's give this one a try... Below is the code you have given us but with a few enhancements:
<div id="container">
<div class="left">
<input type="button" id="button" value="something" />
</div>
<div class="right">
<textarea id="message"></textarea>
</div>
</div>
And the following is the CSS I have attached:
.left {
width: 120px;
float:left;
}
.right {
float:right;
}
#message{
width:400px;
}
#container {
display:inline-block;
}
Now, what I have done is set all of your current divs into one main div, which can hold everything together. I implemented a display:inline-block to help keep everything on one line along with maintaining the text area to be on the right and the button on he left with the cushion you have asked for in-between. To get a better idea of what this does, I have recreated an already done JsFiddle, which can accurately depict what I am describing.
A few things to note, remember that "textarea" can have the values of "rows" and "cols" which will determine how many rows and columns the text area will be, so you really do not need to have width in this aspect, especially if you need more rows vs columns.
Another thing, if you want to learn a bit more conceptually about some CSS tricks, the Almanac is one of the better tools out there to help you understand "why this does that".
Last, I encourage you to play with everybody's JsFiddle to get a better understanding of exactly what you want to see in your own code, every answer that has been presented has their own unique JsFiddle.
If this does not work or you have questions, comment below and we can figure something else out :)
Good luck with your future HTML/CSS coding adventures :)
I have a 50x50 image and an <input type="text" /> field that I want to be on the right side of the image. I've tried this:
<img src="missing-image.png" />
<div name="image_input">
<input type="text" />
</div>
And with this CSS:
#image_input {
position: absolute;
top: 10px;
}
But the text input won't go to the right side of the image. Also as you can see I want it to be centralized with the height of the image and as I can see it won't work too. How I can correct this?
PS: All that is inside a <form>
Position absolute gives you more control:
HTML
<div name="image_input">
<img src="missing-image.png" />
<input type="text" />
</div>
CSS
div {
position:relative;
}
input{
position:absolute;
right:10px;
bottom:20px;
}
Try this:
<div id="image_input">
<img src="missing-image.png" />
<input type="text" />
</div>
and the CSS:
#image_input img {
float: left;
clear: none;
}
Note that I changed the div's "name" attribute to an "id" attribute.
there are a couple of ways to center align text next to an image. you can put it in a list and make the image the list style type. The other thing you can do it properly pad the element to center align it.
Try changing to this:
<div name="image_input">
<img src="missing-image.png" />
<input type="text" />
</div>
And the CSS:
.img {
display: inline-block;
}
To center the height, you might want to use one of the vertical-align options on the input tag.
such as:
input {
vertical-align: middle;
}
I don't use vertical-align very much, so you might have to tweak it a little to get it to work, but see here: http://www.w3schools.com/css/pr_pos_vertical-align.asp