What is the best way to position a div directly following an input field?

Is there a way to have the '.domain.com' appear right after the 'subdomain' input box?

<div style="display:block; ">
<input type="text" placeholder="subdomain" style="width: 245px;">
<div style="float: right;">.domain.com</div>
</div>

Answer №1

<input type="text" placeholder="username" style="width: 200px;float: left;">
<div style="float: left;">.mywebsite.com</div>

sample http://jsfiddle.net/Abcde/1/

Answer №2

Getting accustomed to this

<div style="display:block; ">
<input type="text" placeholder="subdomain" style="width: 300px;vertical-align:top;">
<div style="vertical-align:top; display:inline-block;">.website.com</div>
</div>

See it in action http://example.com/AbC456

Answer №3

Modify the CSS to display the text

<div style="display: inline">.domain.com</div>

Here is the updated fiddle - http://jsfiddle.net/Tmusf/2/

<div style="display:block; ">
  <input type="text" placeholder="subdomain" style="width: 245px;">
  <div style="display: inline">.domain.com</div>
</div>

You can also consider using an inline element like span instead of div and avoid styling it

<div style="display:block; ">
      <input type="text" placeholder="subdomain" style="width: 245px;">
      <span>.domain.com</span>
    </div>

Alternatively, you can directly insert the text .domain.com without any container element

<div style="display:block; ">
          <input type="text" placeholder="subdomain" style="width: 245px;">
          .domain.com
        </div>

Answer №4

<div style="display: block;">
        <input type="text" placeholder="subdomain" style="width: 245px;" />.website.com
    </div>

As per the code provided by Dipak, the above code offers a simple and effective solution to your issue. If you wish to add styles, they can be included within a span tag.

For example:

<div style="display: block;">
        <input type="text" placeholder="subdomain" style="width: 245px;" /><span style="color:Blue;">.website.com</span>
    </div>

Answer №5

this answer is tailored just for you

<div class="section">
     <input type="text" value="" class="section_site" id="website_input" name="website_input">
     <span class="content_inner">.example.org</span> 
      </div>

      <style>
       .section {
        border: 1px solid #EAEAEA;
        height: 40px;
        width: 350px;
    }
    .section_site {
        background: none repeat scroll 0 0 rgba(0, 0, 0, 0);
        border: medium none;
        height: 40px;
        width: 250px;
    }
    .content_inner {
        color: #CCCCCC;
    }
      </style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transform the size and convert an object from a picture into text based on the user's scrolling

I've been intrigued by the scrolling effects used on websites like Google SketchUp and Google Plus. It's fascinating how elements can transform as you scroll down the page. For example, on Google SketchUp's site, the banner starts off integr ...

Switch the Header Image on a Page in WordPress

I am currently using the Sunrise Theme from s5themes.com and I have a question regarding the header image on individual pages. It seems that all pages are displaying the same header image as the homepage, which is not what I want. Attached below is a scre ...

Parallax effect overlay for DIV

Planning to give my website a makeover and I'm thinking of adding some parallax effects to make it more engaging. My idea is to have 3 boxes overlapping each other (with the 2nd and 3rd box appearing blurry). These boxes would be placed at the top of ...

The navigation bar's background color remains static and doesn't update as

Struggling with HTML/CSS and unable to get the NAV bar to display the specified background color. Tried putting the nav in a class, commented out parts of the code, but still couldn't make it work. Despite looking for solutions, I can't figure ou ...

Guide on adjusting the darkness of a MaterialUI Avatar component image and adding text to it

I'm currently working with the Avatar component from Material UI along with Tailwind CSS. I found that by simply adding the image URL to the src, it displays the avatar successfully. <Avatar alt="Cindy Baker" src="https://mui.com/sta ...

The slider feature is malfunctioning on Internet Explorer version 8

Hello everyone, I am facing an issue with my website located at: http://210.48.94.218/~printabl/ When viewed in IE 8, the slider is not functioning properly (it is showing collapsed between the menu and product images section) The theme used for my site ...

Arrangement of items in a grid with various sizes

I have encountered a challenge that I cannot seem to overcome. In my grid system, there are 18 identical items/boxes. I am looking to remove 4 of those items/boxes and combine them into one large item/box. Refer to the wireframe below for guidance on how ...

CSS - How can text and images be effectively combined for a visually appealing design?

We're tasked with designing text in the following format: Text in English XXX Text in English XXX Text in English. The XXX placeholders need to be replaced with images that have the same height as the English text. Is there a better solution for th ...

Exploring the possibilities of CSS grids within the Wordpress platform

After successfully building my website, I am now in the process of converting it into a customizable wordpress theme. One challenge I am facing is integrating a dynamic gallery using CSS grid. The goal is to upload photos, videos, and gifs in Wordpress and ...

Making alterations to the content of a division using getElementById().innerHTML yields no difference

Recently, I've been working on a JS project inspired by a short story from my high school days. The story featured robot crabs living on a small island, and I wanted to create a simulator where players could set the initial parameters and watch as the ...

Stacking a Bootstrap column above another column

Is there a way to stack a bootstrap column on top of another column while maintaining its size and responsiveness? Consider this scenario with 4 columns arranged in a row: https://i.sstatic.net/qug0g.png Upon clicking the Overlay btn, the E column shoul ...

Randomly assigning a unique color to each div upon loading the page

I would like to create an effect where the background color of an icon changes randomly to match the color of the text. There are four predefined color choices available for this randomization. Here is the current code I am working with: HTML: <div ...

What is the best way to vertically center text within a div?

After successfully centering my text horizontally in my div using text-align: center, I'm now faced with the challenge of centering it vertically. Despite my attempts with vertical-align: middle;, I haven't been able to achieve the desired result ...

Tips for positioning bootstrap text-box and button on the same line

I am trying to achieve a layout where the text box and button are aligned in one line using Bootstrap CSS. Here is the code snippet I have been working with: HTML : <div class="new-meows"> <input type="text" class="form-control" > ...

Displaying and hiding the top menu when the div is scrolled

I have developed a script that is designed to display the menu in a shaking motion and hide it as you scroll down. It functions properly when scrolling within the body of the webpage, but I am facing issues when attempting to do so with a div that has an o ...

Is there a way to create an input field that accepts only numbers and behaves like a password field simultaneously?

I am attempting to develop an input field for entering a PIN. I would like the PIN to be masked on mobile devices, similar to how passwords are obscured in password input fields. I came across a suggestion on stackoverflow regarding this, but unfortunately ...

Insider's guide to showcasing code in vibrant colors using Python Django

Context: I am currently working on a Python Django web application and need to showcase code snippets in the browser with syntax highlighting. An example of the code snippet I want to display would be: if True: print("Hello World") I am look ...

The drop-down links vanish into the depths of the webpage's body

Can someone assist with my drop-down menu issue for the link "services"? The link disappears behind the page content when I try to modify it. Any help would be appreciated, thank you! This is the CSS: .bodycontent { margin: 0 25% 0 25%; ...

Ways to hide menu click when hovering over it

As a beginner, I have created a menu that shows options on hover and click. However, I am encountering an issue where clicking on one menu option and then hovering over another menu creates two lists of options. Is there a way to make the clicked menu opti ...

Create a custom calendar in Vue.js that allows you to dynamically disable specific

Recently, I've been working with vue.js and I've come across an issue regarding how to apply a class to past and future days of the current month. Specifically, for March, I need to disable days with numbers 24, 25, 26, 27, 28, 29 in the first ro ...