If you want everything in the foreground and background in focus, you need to work with a higher aperture (say f/8 to f/22). Higher apertures increase the depth of field. Aperture refers to the lens' opening, which in turn impacts how much light gets into the camera. A lower aperture of f/1.2 or f/1.8 lets more light into the lens, and it has the effect of blurring the background elements (referred to as bokeh).